我正在使用TCPDF和FPDI创建一个新的PDF,并希望在一个整页上添加一个图像(具有alpha透明度) . 奇怪的是,TCPDF有时会创建一个PDF,有时只会崩溃而没有错误(即除了标准的响应头(对于text / html),根本不会产生任何输出 . 它总是取决于我传递给图像的尺寸功能:

$this->Image($markupfile,0,0,120, 50, 'png', '', '', true, 300);

然而,工作(尽管图像太小)

$this->Image($markupfile,0,0,1200, 50, 'png', '', '', true, 300);

才不是 . 原始尺寸为宽度: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');

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐