You could extend the TCPDF class with a custom header function, and add image to header, with TCPDF::Image
. There is an example on how to do this within the TCPDF examples
From the example:
<pre>
<code>// Extend the TCPDF class to create custom Header and Footer class MYPDF extends TCPDF { //Page header public function Header() { // get the current page break margin $bMargin = $this->getBreakMargin(); // get current auto-page-break mode $auto_page_break = $this->AutoPageBreak; // disable auto-page-break $this->SetAutoPageBreak(false, 0); // set bacground image $img_file = K_PATH_IMAGES.'image_demo.jpg'; $this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0); // restore auto-page-break status $this->SetAutoPageBreak($auto_page_break, $bMargin); // set the starting point for the page content $this->setPageMark(); } }</code>
</pre>
And use MYPDF
instead of TCPDF
just as you would use TCPDF
. The only thing I don’t know if the PDF body can overlap with the header, but I think it can if you explicitly specify the margins and the header size.
Let me know if this works.
Question and answer is powered by AnsPress.io