[英]fpdi with tcpdf new added text not showing in the pdf
I am trying to adding text in existing pdf using fpdi with tcpdf library.我正在尝试使用 fpdi 和 tcpdf 库在现有的 pdf 中添加文本。 but text are not showing on the pdf.但 pdf 上没有显示文字。 if i search pdf text can be highlighted but it is hidden on pdf.如果我搜索 pdf 文本可以突出显示,但它隐藏在 pdf 上。 i have tried z-index too but still not appear.我也尝试过 z-index 但仍然没有出现。
please see below is my code.请看下面是我的代码。
$pdf = new FPDI();
$pageCount = $pdf->setSourceFile('102215_2019_unlocked.pdf');
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
//$pdf->setPrintHeader(false);
// create a page (landscape or portrait depending on the imported page size)
if ($size['w'] > $size['h']) {
$pdf->AddPage('L', array($size['w'], $size['h']));
// Font size 1/3 Height if it landscape
$fontsize = $size['h'] / 3;
} else {
$pdf->AddPage('P', array($size['w'], $size['h']));
// Font size 1/3 Width if it portrait
$fontsize = $size['w'] / 3;
}
$html = '<h1 style="z-index:-1;color:black;">[![HTML Example][1]][1]</h1>';
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->useTemplate($templateId);
// $pdf->SetAlpha(1);
}
$pdf->output();
ok i have found answer myself finally.好的,我终于自己找到了答案。
usetemplate function was needed to put before the text and my image applied. usetemplate function 需要放在文本和我的图像应用之前。
like this像这样
$pdf->useTemplate($templateId);
$pdf->StartTransform();
$pdf->Image('logo.png', 175, 5, 35, 0, 'PNG','https://franchimp.com');
$pdf->SetFont('Helvetica', 'B', 70);
$pdf->SetTextColor(31, 156, 239);
$pdf->SetAlpha(0.5);
$pdf->SetXY(20, 180);
$pdf->Rotate(35);
$pdf->Write(0, 'franchimp.com');
$pdf->StopTransform();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.