【发布时间】:2011-11-06 09:39:23
【问题描述】:
我正在尝试为 pdf 工作表构建一个标题生成器。
我选择的技术是: FPDF 和 FPDI
现在,我正在过渡到 TCPDF 和 FPDI,因为权力已经决定我们需要水印(透明胶片)。
根据 FPDI 网站,切换就像将所有 require/include 语句更改为 tcpdf.php 而不是 fpdf.php 一样简单,但在下面的代码中:
//... 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');
似乎会产生一个错误,上面写着: 警告:在此处的适当目录内容中除以零/lib/fpdf/fpdf.php 第 819 行
我已经删除了我的代码中对 fpdf 的所有引用,但它似乎仍在提出这个问题。
另外,当我尝试使用从 FPDF 继承的方法打印到 PDF 时:
$pdf->SetFont('Arial','B',25);
$pdf->Cell(40,10,'Hello World!');
这将生成文本。此外,FPDI 网站说 FPDI 对 FPDF_TPL 文件有依赖关系,查看该文件告诉我它扩展了 FPDF。
我的问题是:如何配置 FPDI 以使用 TCPDF 而不是 FPDF?
【问题讨论】: