Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write html to custom header tcpdf

Tags:

tcpdf

I'm struggling to understand how the header function is working in tcpdf.

Is is possible to use $pdf->writeHTML to the header?

http://www.tcpdf.org/examples/example_003.phps

I would like to display 3 columns in the header.

 Column1 Column2 Column3
like image 255
user3906056 Avatar asked Sep 22 '14 13:09

user3906056


People also ask

How do I add a header in Tcpdf?

Below is the script to put in the header data: // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'PQR', 'XYZ');

How do I upload an image to Tcpdf?

$tcpdf = new TCPDF_TCPDF(); $img = file_get_contents(Mage::getBaseDir('media') . '/dhl/logo. jpg'); $PDF_HEADER_LOGO = $tcpdf->Image('@' . $img);//any image file.


1 Answers

Problem solved, credits to Simon @ https://sourceforge.net/p/tcpdf/discussion/435311/thread/505a9e13/

class MYPDF extends TCPDF {
public function Header() {
    $headerData = $this->getHeaderData();
    $this->SetFont('helvetica', 'B', 10);
    $this->writeHTML($headerData['string']);
}
}
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->setHeaderData($ln='', $lw=0, $ht='', $hs='<table cellspacing="0" cellpadding="1" border="1"><tr><td rowspan="3">test</td><td>test</td></tr></table>', $tc=array(0,0,0), $lc=array(0,0,0));
like image 62
user3906056 Avatar answered Jan 27 '23 11:01

user3906056