我需要在用户需要时合并PDF文件.文件已经存在,一切都很好.我正在使用fallowing代码来合并文件:
class concat_pdf extends FPDI
{
var $files = array();
function setFiles($files)
{
$this->files = $files;
}
function concat()
{
foreach($this->files AS $file)
{
$pagecount = $this->setSourceFile($file);
for($i = 1; $i <= $pagecount; $i++)
{
$this->AddPage('P');
$tplidx = $this->ImportPage($i);
$this->useTemplate($tplidx);
}
}
}
}
$pdf = new concat_pdf();
$pdf->setFiles($files); //$files is an array with existing PDF files.
$pdf->concat();
$pdf->Output("bulk.pdf", "D");
Run Code Online (Sandbox Code Playgroud)
所有文件都已合并,所有内容都在那里.问题是,在新文件的每个页面的顶部,出现一条黑线.内容,边距等都与原始文件完全相同,但这条线无处不在(我可以告诉).它不厚,但清晰可见.它不会混淆其他内容或任何东西,但在那里不需要,我需要删除它.
我已经尝试将ImportPage()函数的第二个参数更改为文档中描述的所有选项,但没有任何区别.因为这是我看到的唯一可以在这几行代码中改变的东西,我真的不知道是什么原因导致黑线出现.我搜索过类似的问题,但到目前为止 - 没有运气.有人有想法吗?提前致谢!

小智 22
更好的事情是因为您不必修改源代码就是添加以下行:
$this->setPrintHeader(false);
$this->setPrintFooter(false);
Run Code Online (Sandbox Code Playgroud)
在你的concat()函数的开头.
小智 5
为了避免编辑 TCPDF 库,请覆盖扩展类中的 Footer 和 Header 方法。
class concat_pdf extends FPDI
{
public function Footer() {}
public function Header() {}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7225 次 |
| 最近记录: |