2016-07-01 46 views
0

我正在嘗試做一個頁面組,雖然它不工作。現在它正在做第1頁,共4頁。我需要它按組編號頁面。於是就有一共有4頁,我需要第1頁第2,然後重新開始第1頁2 類ManafestPrint的擴展TCPDF {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'); 

回答

0

原來我的頁碼編號設置不正確。在我的頭,我需要改變這樣的:

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); 
    }