TCPDF and FPDI: Is there a separate version of FPDI for TCPDF than for FPDF
I'm trying to build an header generator for pdf worksheets.
My choice of technologies were: FPDF and FPDI
Now, I'm transistioning to TCPDF and FPDI, because the powers that be have decided we need water marks (transparencies).
According to the FPDI website, switching is as easy as changing all your require/include statements to say tcpdf.php instead of fpdf.php but in my code below:
//... Code to generate appropriate Graph ...
PDFGenHelper::saveIMG($graph,$imgfilepath);
$filename = "template.pdf";
$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile($filename);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->Image($imgfilepath, 168, 13, 35, 65);
$pdf->Write(5, "This is just a simple text"); //This line
$pdf->Output($dircache.$userID.'_'.$excerciseID.'_package.pdf', 'F');
Seems to generate an error that says: Warning: Division by zero in Appropriate directory stuff here/lib/fpdf/fpdf.php on line 819
I've removed all the references to fpdf in my code but it seems to still be coming up with that.
Also, when I try to print to the PDF using the inherited methods from FPDF:
$pdf->SetFont('Arial','B',25);
$pdf->Cell(40,10,'Hello World!');
This will generate text. In addition the FPDI website says FPDI has 开发者_Go百科a Dependency on FPDF_TPL file which looking into the file tells me it extends FPDF.
So to my question: How do you configure FPDI to work with TCPDF instead of FPDF?
If the error is rised in lib/fpdf/fpdf.php then you still have required fpdf.php before TCPDF.
Also: If it's just the transparency you're missing, just use AlphaPDF from the script section.
精彩评论