296 |
aurelien |
1 |
<?php
|
|
|
2 |
//============================================================+
|
|
|
3 |
// File name : example_051.php
|
|
|
4 |
// Begin : 2009-04-16
|
|
|
5 |
// Last Update : 2010-08-08
|
|
|
6 |
//
|
|
|
7 |
// Description : Example 051 for TCPDF class
|
|
|
8 |
// Full page background
|
|
|
9 |
//
|
|
|
10 |
// Author: Nicola Asuni
|
|
|
11 |
//
|
|
|
12 |
// (c) Copyright:
|
|
|
13 |
// Nicola Asuni
|
|
|
14 |
// Tecnick.com s.r.l.
|
|
|
15 |
// Via Della Pace, 11
|
|
|
16 |
// 09044 Quartucciu (CA)
|
|
|
17 |
// ITALY
|
|
|
18 |
// www.tecnick.com
|
|
|
19 |
// info@tecnick.com
|
|
|
20 |
//============================================================+
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Creates an example PDF TEST document using TCPDF
|
|
|
24 |
* @package com.tecnick.tcpdf
|
|
|
25 |
* @abstract TCPDF - Example: Full page background
|
|
|
26 |
* @author Nicola Asuni
|
|
|
27 |
* @copyright 2004-2009 Nicola Asuni - Tecnick.com S.r.l (www.tecnick.com) Via Della Pace, 11 - 09044 - Quartucciu (CA) - ITALY - www.tecnick.com - info@tecnick.com
|
|
|
28 |
* @link http://tcpdf.org
|
|
|
29 |
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
|
|
30 |
* @since 2009-04-16
|
|
|
31 |
*/
|
|
|
32 |
|
|
|
33 |
require_once('../config/lang/eng.php');
|
|
|
34 |
require_once('../tcpdf.php');
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
// Extend the TCPDF class to create custom Header and Footer
|
|
|
38 |
class MYPDF extends TCPDF {
|
|
|
39 |
//Page header
|
|
|
40 |
public function Header() {
|
|
|
41 |
// full background image
|
|
|
42 |
// store current auto-page-break status
|
|
|
43 |
$bMargin = $this->getBreakMargin();
|
|
|
44 |
$auto_page_break = $this->AutoPageBreak;
|
|
|
45 |
$this->SetAutoPageBreak(false, 0);
|
|
|
46 |
$img_file = K_PATH_IMAGES.'image_demo.jpg';
|
|
|
47 |
$this->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
|
|
|
48 |
// restore auto-page-break status
|
|
|
49 |
$this->SetAutoPageBreak($auto_page_break, $bMargin);
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
// create new PDF document
|
|
|
54 |
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
|
|
55 |
|
|
|
56 |
// set document information
|
|
|
57 |
$pdf->SetCreator(PDF_CREATOR);
|
|
|
58 |
$pdf->SetAuthor('Nicola Asuni');
|
|
|
59 |
$pdf->SetTitle('TCPDF Example 051');
|
|
|
60 |
$pdf->SetSubject('TCPDF Tutorial');
|
|
|
61 |
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
|
|
|
62 |
|
|
|
63 |
// set header and footer fonts
|
|
|
64 |
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
|
|
65 |
|
|
|
66 |
// set default monospaced font
|
|
|
67 |
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
|
|
68 |
|
|
|
69 |
//set margins
|
|
|
70 |
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
|
|
|
71 |
$pdf->SetHeaderMargin(0);
|
|
|
72 |
$pdf->SetFooterMargin(0);
|
|
|
73 |
|
|
|
74 |
// remove default footer
|
|
|
75 |
$pdf->setPrintFooter(false);
|
|
|
76 |
|
|
|
77 |
//set auto page breaks
|
|
|
78 |
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
|
|
|
79 |
|
|
|
80 |
//set image scale factor
|
|
|
81 |
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
|
|
82 |
|
|
|
83 |
//set some language-dependent strings
|
|
|
84 |
$pdf->setLanguageArray($l);
|
|
|
85 |
|
|
|
86 |
// ---------------------------------------------------------
|
|
|
87 |
|
|
|
88 |
// set font
|
|
|
89 |
$pdf->SetFont('times', '', 48);
|
|
|
90 |
|
|
|
91 |
// add a page
|
|
|
92 |
$pdf->AddPage();
|
|
|
93 |
|
|
|
94 |
// Print a text
|
|
|
95 |
$html = '<span style="background-color:yellow;color:blue;"> PAGE 1 </span>
|
|
|
96 |
<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>';
|
|
|
97 |
$pdf->writeHTML($html, true, false, true, false, '');
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
// add a page
|
|
|
101 |
$pdf->AddPage();
|
|
|
102 |
|
|
|
103 |
// Print a text
|
|
|
104 |
$html = '<span style="background-color:yellow;color:blue;"> PAGE 2 </span>';
|
|
|
105 |
$pdf->writeHTML($html, true, false, true, false, '');
|
|
|
106 |
|
|
|
107 |
// ---------------------------------------------------------
|
|
|
108 |
|
|
|
109 |
//Close and output PDF document
|
|
|
110 |
$pdf->Output('example_051.pdf', 'I');
|
|
|
111 |
|
|
|
112 |
//============================================================+
|
|
|
113 |
// END OF FILE
|
|
|
114 |
//============================================================+
|