2009-09-30 09:18:36 +00:00
|
|
|
<?php
|
|
|
|
//============================================================+
|
|
|
|
// File name : example_051.php
|
|
|
|
// Begin : 2009-04-16
|
2013-05-14 20:28:42 +00:00
|
|
|
// Last Update : 2013-05-14
|
2010-05-21 16:47:01 +00:00
|
|
|
//
|
2009-09-30 09:18:36 +00:00
|
|
|
// Description : Example 051 for TCPDF class
|
|
|
|
// Full page background
|
2010-05-21 16:47:01 +00:00
|
|
|
//
|
2009-09-30 09:18:36 +00:00
|
|
|
// Author: Nicola Asuni
|
2010-05-21 16:47:01 +00:00
|
|
|
//
|
2009-09-30 09:18:36 +00:00
|
|
|
// (c) Copyright:
|
|
|
|
// Nicola Asuni
|
2011-12-23 17:19:43 +00:00
|
|
|
// Tecnick.com LTD
|
2009-09-30 09:18:36 +00:00
|
|
|
// www.tecnick.com
|
|
|
|
// info@tecnick.com
|
|
|
|
//============================================================+
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an example PDF TEST document using TCPDF
|
|
|
|
* @package com.tecnick.tcpdf
|
|
|
|
* @abstract TCPDF - Example: Full page background
|
|
|
|
* @author Nicola Asuni
|
|
|
|
* @since 2009-04-16
|
|
|
|
*/
|
|
|
|
|
2013-05-14 20:28:42 +00:00
|
|
|
// Include the main TCPDF library (search for installation path).
|
|
|
|
require_once('tcpdf_include.php');
|
2009-09-30 09:18:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Extend the TCPDF class to create custom Header and Footer
|
|
|
|
class MYPDF extends TCPDF {
|
|
|
|
//Page header
|
|
|
|
public function Header() {
|
2011-06-01 08:45:43 +00:00
|
|
|
// get the current page break margin
|
2010-03-27 17:52:11 +00:00
|
|
|
$bMargin = $this->getBreakMargin();
|
2011-06-01 08:45:43 +00:00
|
|
|
// get current auto-page-break mode
|
2009-04-25 10:15:56 +00:00
|
|
|
$auto_page_break = $this->AutoPageBreak;
|
2011-06-01 08:45:43 +00:00
|
|
|
// disable auto-page-break
|
2009-09-30 09:18:36 +00:00
|
|
|
$this->SetAutoPageBreak(false, 0);
|
2011-06-01 08:45:43 +00:00
|
|
|
// set bacground image
|
2009-04-25 10:15:56 +00:00
|
|
|
$img_file = K_PATH_IMAGES.'image_demo.jpg';
|
2010-03-27 17:52:11 +00:00
|
|
|
$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
|
|
|
|
// restore auto-page-break status
|
|
|
|
$this->SetAutoPageBreak($auto_page_break, $bMargin);
|
2011-06-01 08:45:43 +00:00
|
|
|
// set the starting point for the page content
|
|
|
|
$this->setPageMark();
|
2009-09-30 09:18:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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));
|
2009-04-25 10:15:56 +00:00
|
|
|
|
|
|
|
// set default monospaced font
|
|
|
|
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
2009-09-30 09:18:36 +00:00
|
|
|
|
2013-05-14 20:28:42 +00:00
|
|
|
// set margins
|
2009-09-30 09:18:36 +00:00
|
|
|
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
|
|
|
$pdf->SetHeaderMargin(0);
|
2009-04-25 10:15:56 +00:00
|
|
|
$pdf->SetFooterMargin(0);
|
|
|
|
|
2009-09-30 09:18:36 +00:00
|
|
|
// remove default footer
|
|
|
|
$pdf->setPrintFooter(false);
|
|
|
|
|
2013-05-14 20:28:42 +00:00
|
|
|
// set auto page breaks
|
2009-09-30 09:18:36 +00:00
|
|
|
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
|
|
|
|
2013-05-14 20:28:42 +00:00
|
|
|
// set image scale factor
|
2010-05-21 16:47:01 +00:00
|
|
|
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
2009-09-30 09:18:36 +00:00
|
|
|
|
2013-05-14 20:28:42 +00:00
|
|
|
// set some language-dependent strings (optional)
|
|
|
|
if (file_exists(dirname(__FILE__).'/lang/eng.php')) {
|
|
|
|
require_once(dirname(__FILE__).'/lang/eng.php');
|
|
|
|
$pdf->setLanguageArray($l);
|
|
|
|
}
|
2009-09-30 09:18:36 +00:00
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
// set font
|
|
|
|
$pdf->SetFont('times', '', 48);
|
|
|
|
|
|
|
|
// add a page
|
|
|
|
$pdf->AddPage();
|
|
|
|
|
2010-05-21 16:47:01 +00:00
|
|
|
// Print a text
|
|
|
|
$html = '<span style="background-color:yellow;color:blue;"> PAGE 1 </span>
|
|
|
|
<p stroke="0.2" fill="true" strokecolor="yellow" color="blue" style="font-family:helvetica;font-weight:bold;font-size:26pt;">You can set a full page background.</p>';
|
|
|
|
$pdf->writeHTML($html, true, false, true, false, '');
|
|
|
|
|
2009-09-30 09:18:36 +00:00
|
|
|
|
|
|
|
// add a page
|
|
|
|
$pdf->AddPage();
|
|
|
|
|
2010-05-21 16:47:01 +00:00
|
|
|
// Print a text
|
|
|
|
$html = '<span style="background-color:yellow;color:blue;"> PAGE 2 </span>';
|
|
|
|
$pdf->writeHTML($html, true, false, true, false, '');
|
2009-09-30 09:18:36 +00:00
|
|
|
|
2011-06-01 08:45:43 +00:00
|
|
|
// --- 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, 0, 0, 210, 297, '', '', '', false, 300, '', 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 = '<span style="color:white;text-align:center;font-weight:bold;font-size:80pt;">PAGE 3</span>';
|
|
|
|
$pdf->writeHTML($html, true, false, true, false, '');
|
|
|
|
|
2009-09-30 09:18:36 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
//Close and output PDF document
|
|
|
|
$pdf->Output('example_051.pdf', 'I');
|
|
|
|
|
|
|
|
//============================================================+
|
2011-06-01 08:45:43 +00:00
|
|
|
// END OF FILE
|
2009-09-30 09:18:36 +00:00
|
|
|
//============================================================+
|