source: sipes/libraries/tcpdf/examples/example_003.php @ 307d09d

stableversion-3.0
Last change on this file since 307d09d was 307d09d, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agregaron las librerias

  • Propiedad mode establecida a 100755
File size: 3.5 KB
Línea 
1<?php
2//============================================================+
3// File name   : example_003.php
4// Begin       : 2008-03-04
5// Last Update : 2010-08-08
6//
7// Description : Example 003 for TCPDF class
8//               Custom Header and Footer
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: Custom Header and Footer
26 * @author Nicola Asuni
27 * @since 2008-03-04
28 */
29
30require_once('../config/lang/eng.php');
31require_once('../tcpdf.php');
32
33
34// Extend the TCPDF class to create custom Header and Footer
35class MYPDF extends TCPDF {
36
37        //Page header
38        public function Header() {
39                // Logo
40                $image_file = K_PATH_IMAGES.'logo_example.jpg';
41                $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
42                // Set font
43                $this->SetFont('helvetica', 'B', 20);
44                // Title
45                $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
46        }
47
48        // Page footer
49        public function Footer() {
50                // Position at 15 mm from bottom
51                $this->SetY(-15);
52                // Set font
53                $this->SetFont('helvetica', 'I', 8);
54                // Page number
55                $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
56        }
57}
58
59// create new PDF document
60$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
61
62// set document information
63$pdf->SetCreator(PDF_CREATOR);
64$pdf->SetAuthor('Nicola Asuni');
65$pdf->SetTitle('TCPDF Example 003');
66$pdf->SetSubject('TCPDF Tutorial');
67$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
68
69// set default header data
70$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
71
72// set header and footer fonts
73$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
74$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
75
76// set default monospaced font
77$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
78
79//set margins
80$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
81$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
82$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
83
84//set auto page breaks
85$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
86
87//set image scale factor
88$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
89
90//set some language-dependent strings
91$pdf->setLanguageArray($l);
92
93// ---------------------------------------------------------
94
95// set font
96$pdf->SetFont('times', 'BI', 12);
97
98// add a page
99$pdf->AddPage();
100
101// set some text to print
102$txt = <<<EOD
103TCPDF Example 003
104
105Custom page header and footer are defined by extending the TCPDF class and overriding the Header() and Footer() methods.
106EOD;
107
108// print a block of text using Write()
109$pdf->Write($h=0, $txt, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0);
110
111// ---------------------------------------------------------
112
113//Close and output PDF document
114$pdf->Output('example_003.pdf', 'I');
115
116//============================================================+
117// END OF FILE                                               
118//============================================================+
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.