require_once('TCPDF/tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetHeaderMargin(20); // sets the top margin for the header to 20mm $pdf->AddPage(); $pdf->Output('example.pdf', 'D');
include('tcpdf/config/lang/eng.php'); include('tcpdf/tcpdf.php'); $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->setHeaderMargin(20); $pdf->setHeaderData('Example Company', '', 'Example Document', '', array(0,0,0), array(255,255,255)); $pdf->setFooterData(array(0,0,0), array(255,255,255)); $pdf->AddPage(); // add content to the PDF $pdf->Output('example.pdf', 'I');This example also sets the header margin to 20mm, but it also adds information to the header and footer of the PDF document. The setHeaderData method is used to provide the company name, document title and formatting options for the header, while the setFooterData method adds formatting options for the footer. Finally, the Output method is called to display the PDF in the browser. Package library: TCPDF.