TCPDF set different headers for different pages in one document

后端 未结 8 627
终归单人心
终归单人心 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:44

    I found this to be the solution with the lightest touch:

    class MYPDF extends TCPDF {
    
        //Page header
        public function AddNewHeader($newTitle) {
            $this->header_xobj_autoreset = true;
            $this->header_title = $newTitle;
        }
    
    }
    

    Be sure to call TCPDF::setHeaderData() first. Next, call this function before every AddPage() event, or, if you're looping through data and relying on tcpdf to add pages, call it after every element add. It breaks the caching of the header, but allows the user to put a new and custom header on each page. All the elements returned by TCPDF::getHeaderData() can be updated in this way.

提交回复
热议问题