【发布时间】:2017-02-16 09:44:07
【问题描述】:
我已经使用 tcpdf 成功生成了 pdf 现在我想在一张纸上制作一页到四页
脚本没有问题...我只想让它自动设置 persheet 4,这样用户就不必在每次打印时都配置设置..有没有办法做到这一点,以便我不必将我的编码更改太多
按照建议,我使用 fpdi
$pdf->Output($st.'/TEST.PDF', 'F');
require_once(APPPATH.'libraries/FPDI/fpdf_tpl.php');
require_once(APPPATH.'libraries/FPDI/fpdi.php');
$filename = $st.'/TEST.PDF';
$pdfx = new FPDI();
//exit();
$pageCount = $pdfx->setSourceFile($filename);
//echo $pageCount;
//exit();
$w = $pdfx->GetPageWidth() / 2 - 15;
$h = 0;
$_x = $x = 10;
$_y = $y = 10;
$pdfx->AddPage();
for ($n = 1; $n <= $pageCount; $n++) {
$tplIdx = $pdfx->importPage($n);
$size = $pdfx->useTemplate($tplIdx, $x, $y, $w);
$pdfx->Rect($x, $y, $size['w'], $size['h']);
$h = max($h, $size['h']);
if ($n % 2 == 0) {
$y += $h + 10;
$x = $_x;
$h = 0;
} else {
$x += $w + 10;
}
if ($n % 4 == 0 && $n != $pageCount) {
$pdfx->AddPage();
$x = $_x;
$y = $_y;
}
}
$pdfx->Output('thumbnails.pdf', 'F');
但我收到一条错误消息
遇到了 PHP 错误
严重性:警告
消息:fopen():不支持远程主机文件访问,file://thumbnails.pdf
文件名:include/tcpdf_static.php
行号:2466 遇到 PHP 错误
严重性:警告
消息:fopen(file://thumbnails.pdf):无法打开流:找不到合适的包装器
文件名:include/tcpdf_static.php
行号:2466 TCPDF 错误:无法创建输出文件:thumbnails.pdf
这是 codeignighter 中的冲突库吗?我加载 tcpdf 然后我需要一次 fpdi 库
哦,我想我知道问题出在保存位置...没关系,我将输出重新编辑为 $pdfx->输出('thumbnails.pdf', 'I');
【问题讨论】: