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, null, 0, 210, 297, '', '', '', false, 300, 'C', false, false, 0); // restore auto-page-break status $this->setAutoPageBreak($auto_page_break, $bMargin); // set the starting point for the page content $this->setPageMark(); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->setCreator(PDF_CREATOR); $pdf->setAuthor('Nicola Asuni'); $pdf->setTitle('TCPDF Example 051'); $pdf->setSubject('TCPDF Tutorial'); $pdf->setKeywords('TCPDF, PDF, example, test, guide'); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); // set default monospaced font $pdf->setDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->setMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->setHeaderMargin(0); $pdf->setFooterMargin(0); // remove default footer $pdf->setPrintFooter(false); // set auto page breaks $pdf->setAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__).'/lang/eng.php')) { require_once(dirname(__FILE__).'/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->setFont('times', '', 48); // add a page $pdf->AddPage(); // Print a text $html = ' PAGE 1
You can set a full page background.
'; $pdf->writeHTML($html, true, false, true, false, ''); // add a page $pdf->AddPage(); // Print a text $html = ' PAGE 2 '; $pdf->writeHTML($html, true, false, true, false, ''); // --- example with background set on page --- // remove default header $pdf->setPrintHeader(false); // add a page $pdf->AddPage(); // -- set new background --- // get the current page break margin $bMargin = $pdf->getBreakMargin(); // get current auto-page-break mode $auto_page_break = $pdf->getAutoPageBreak(); // disable auto-page-break $pdf->setAutoPageBreak(false, 0); // set bacground image $img_file = K_PATH_IMAGES.'image_demo.jpg'; $pdf->Image($img_file, null, 0, 210, 297, '', '', '', false, 300, 'C', false, false, 0); // restore auto-page-break status $pdf->setAutoPageBreak($auto_page_break, $bMargin); // set the starting point for the page content $pdf->setPageMark(); // Print a text $html = 'PAGE 3'; $pdf->writeHTML($html, true, false, true, false, ''); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_051.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+