我正在使用 TCPDF 和 FPDI 创建一个新的 PDF,并希望在整个页面上添加一个图像(具有 alpha 透明度)。奇怪的是,TCPDF 有时会创建一个 PDF,有时只是崩溃而没有错误(即,除了标准响应标头(用于文本/html)之外,根本不产生任何输出。它总是取决于我传递给图像的尺寸功能:
$this->Image($markupfile,0,0,120, 50, 'png', '', '', true, 300);
有效(尽管图像太小),但是
$this->Image($markupfile,0,0,1200, 50, 'png', '', '', true, 300);
才不是。原始尺寸为 width: 968px; 高度:685px;
require_once "config/sessions_class.php";
require_once "config/sanitation_class.php";
require_once('tcpdf/tcpdf.php');
require_once('tcpdf/config/lang/eng.php');
require_once('FPDF/fpdi.php');
require_once('config/settings.php');
require_once('phpfpm/pdfVersion.php');
class concatPdf extends FPDI{
....
function concat() {
$dir = $this->dir;
$pagecount = $this->setSourceFile($dir.$this->file);
for ($i = 1; $i <= $pagecount; $i++) {
$this->_tplIdx = $this->importPage($i);
$s = $this->getTemplatesize($this->_tplIdx);
$this->AddPage($s['w'] > $s['h'] ? 'L' : 'P', array($s['w'], $s['h']));
$this->useTemplate($this->_tplIdx);
$markupfile = "markups/".$this->pdfid."_".$i.".png";
if ( file_exists ($markupfile)) {
$this->Image($markupfile,0,0,1020, 50, 'png', '', '', true, 300);
}
}
}
....
}
$filename;
$pdf = new concatPdf();
$pdf->setImageScale(1.53);
$pdf->SetAutoPageBreak(true, 40);
$pdf->setFontSubsetting(false);
$pdf->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT);
$pdf->concat();
$pdf->Output('ed_'."filename", 'I');