Php TCPDF-将“贝茨编号”添加到合并PDF
我目前正在使用TCPDI将四个文档合并到一个PDF中,并使用一个变量临时存储文档。是否可以从第三页开始将贝茨编号添加到文件中?前两页是一封求职信。提前感谢你为我指明了正确的方向Php TCPDF-将“贝茨编号”添加到合并PDF,php,tcpdf,Php,Tcpdf,我目前正在使用TCPDI将四个文档合并到一个PDF中,并使用一个变量临时存储文档。是否可以从第三页开始将贝茨编号添加到文件中?前两页是一封求职信。提前感谢你为我指明了正确的方向 require_once('../tcpdf/tcpdf.php'); require_once('../tcpdf/tcpdi.php'); // Create new PDF document. $pdf = new TCPDI(); // iterate through
require_once('../tcpdf/tcpdf.php');
require_once('../tcpdf/tcpdi.php');
// Create new PDF document.
$pdf = new TCPDI();
// iterate through the files
foreach ($filesarray AS $file) {
// get the page count
$pageCount = $pdf->setSourceFile($file);
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
// add a page with the same orientation and size
$pdf->AddPage($size['orientation'], $size);
// Set page boxes from imported page 1.
$pdf->setPageFormatFromTemplatePage($pageNo, $size['orientation']);
// use the imported page
$pdf->useTemplate($templateId);
}
}
// Output the new PDF
$attachment = $pdf->Output("Merged.pdf", "S");
我不熟悉Bates系统,但我所做的是添加页码作为标签,并检查PageNo变量/索引以确定何时显示batesNo 用于标签。请参阅TCPDF文档 *未测试的代码
<?php
// iterate through the files
foreach ($filesarray AS $file) {
// get the page count
$pageCount = $pdf->setSourceFile($file);
$batesNo = 0000000001; //initialize*****
// iterate through all pages
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
// import a page
$templateId = $pdf->importPage($pageNo);
// get the size of the imported page
$size = $pdf->getTemplateSize($templateId);
/***********NEW BLOCK*******/
if ($pageNo > 3) {
$pdf->SetTitle('JonesNo-'.$batesNo);
} else {
$pdf->SetTitle($pageNo);
}
////////////////////////
// add a page with the same orientation and size
$pdf->AddPage($size['orientation'], $size);
// Set page boxes from imported page 1.
$pdf->setPageFormatFromTemplatePage($pageNo, $size['orientation']);
// use the imported page
$pdf->useTemplate($templateId);
}
}
?>