TCPDF set different headers for different pages in one document

后端 未结 8 621
终归单人心
终归单人心 2021-02-08 04:50

Is there a way to have a different header logo for the 1st page in a document and different for the 2nd page?

I thought that changing the header data between adding page

8条回答
  •  无人及你
    2021-02-08 05:50

    If you wish to have a cover page without header and footer and internal pages with them, there is an easier way to handle it. Simply turn off the header and footer print via 'setPrintHeader' and 'setPrintFooter' as follows:

    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    
    $pdf->AddPage();
    $pdf->SetFont("freesans", "B", 20);
    $pdf->Cell(0,10,"COVER TEXT",1,1,'C');
    
    $pdf->setPrintHeader(true);
    $pdf->setPrintFooter(true);
    
    $pdf->setHeaderFont(array("freesans", "", 9));
    $pdf->SetHeaderData('', '', 'Document Title', 'Document Header Text');
    $pdf->AddPage();
    $pdf->SetFont("freesans", "B", 20);
    $pdf->Cell(0,10,"Internal text",1,1,'C');
    
    $pdf->Output("HappyCover.pdf", "I");
    

    Enjoy!

提交回复
热议问题