TCPDF - 添加 "Bates Numbering" 到合并的 PDF

TCPDF - Add "Bates Numbering" to merged PDF

我目前正在使用 TCPDI 将四个文档合并为一个 PDF,并使用变量临时存储文档。是否可以在文件中添加 "Bates Numbering",从第三页开始? (前两页是一封求职信。)在此先感谢您为我指明正确的方向

    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 variable/index 以确定何时显示您的 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);
        }
        }



    ?>