【问题标题】:TCPDF Cannot get my formatting correctTCPDF 无法让我的格式正确
【发布时间】:2016-07-01 21:39:30
【问题描述】:

我正在尝试做一个页面组,虽然它不起作用。现在它正在做第 1 页,共 4 页。我需要它按组对页面进行编号。所以总共会有 4 页,我需要第 1 页,共 2 页,然后从第 1 页,共 2 页开始。 类 ManafestPrint 扩展 TCPDF {

  //Page header
    public function Header()
    {
        global $pickUpDate;

        // Set font
        $this->SetFont('helvetica', 'B', 20);
        // Title
        $titleHTML = '
                <table width="100%" border="0" style="font-weight: bold; font-size: 9pt;">
                    <tr>
                        <td width="25%" align="left">PICK UP DATE: '.$pickUpDate.'</td>
                        <td width="50%" align="center" style="font-size: 16pt;">SHIPPING MANIFEST</td>
                        <td width="25%" align="right">Page '.$this->getAliasNumPage().' of '.$this->getAliasNbPages().'</td>
                    </tr>
                </table>
            ';
        $this->writeHTMLCell(280, 25, 7, 5, $titleHTML);
    }
}

这是我的页面布局

        $pdf = new ManifestPrint('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $pdf->SetMargins(0, 12, 0);
        $pdf->SetAutoPageBreak(true, 10);
        $pdf->startPageGroup();
        $pdf->AddPage();
        $pdf->writeHTMLCell(280, 0, 5, 15, $shipperCarierData, 0, 0, false, true, 'C', true);
        $pdf->writeHTMLCell(280, 0, 3, 35, $tableData, 0, 0, false, true, 'C', true);

        $pdf->AddPage();
        $pdf->lastPage();
        $pdf->writeHTMLCell(280, 0, 5, 160, $disclaimerHTML, 0, 0, false, true, 'C', true);
        $pdf->startPageGroup();
        $pdf->AddPage();

        $pdf->writeHTMLCell(280, 0, 5, 15, $shipperCarierData1, 0, 0, false, true, 'C', true);

        $pdf->writeHTMLCell(280, 0, 3, 35, $tableData1, 0, 0, false, true, 'C', true);



       $pdf->AddPage();
       $pdf->lastPage();
       $pdf->writeHTMLCell(280, 0, 5, 160, $disclaimerHTML, 0, 0, false, true, 'C', true);
       $pdf->Output('print_manifest.pdf', 'I');

【问题讨论】:

    标签: php tcpdf


    【解决方案1】:

    原来我的页码设置不正确。在我的标题中,我需要更改:

    public function Header()
        {
            global $pickUpDate;
    
        // Set font
        $this->SetFont('helvetica', 'B', 20);
        // Title
        $titleHTML = '
                <table width="100%" border="0" style="font-weight: bold; font-size: 9pt;">
                    <tr>
                        <td width="25%" align="left">PICK UP DATE: '.$pickUpDate.'</td>
                        <td width="50%" align="center" style="font-size: 16pt;">SHIPPING MANIFEST</td>
                        <td width="25%" align="right">Page '.$this->getAliasNumPage().' of '.$this->getAliasNbPages().'</td>
                    </tr>
                </table>
            ';
        $this->writeHTMLCell(280, 25, 7, 5, $titleHTML);
    }
    

    }

    到这里:

     public function Header()
        {
            global $pickUpDate;
    
            // Set font
            $this->SetFont('helvetica', 'B', 20);
            // Title
            $titleHTML = '
                    <table width="100%" border="0" style="font-weight: bold; font-size: 9pt;">
                        <tr>
                            <td width="25%" align="left">PICK UP DATE: '.$pickUpDate.'</td>
                            <td width="50%" align="center" style="font-size: 16pt;">SHIPPING MANIFEST</td>
                            <td width="25%" align="right">Page '.$this->getPageNumGroupAlias().' of '.$this->getPageGroupAlias().'</td>
                        </tr>
                    </table>
                ';
            $this->writeHTMLCell(280, 25, 7, 5, $titleHTML);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 1970-01-01
      • 2016-06-03
      • 1970-01-01
      • 2014-02-08
      • 2023-03-14
      • 1970-01-01
      相关资源
      最近更新 更多