source: sipes/libraries/tcpdf/examples/example_013.php

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

se agregaron las librerias

  • Propiedad mode establecida a 100755
File size: 6.6 KB
Línea 
1<?php
2//============================================================+
3// File name   : example_013.php
4// Begin       : 2008-03-04
5// Last Update : 2010-08-08
6//
7// Description : Example 013 for TCPDF class
8//               Graphic Transformations
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: Graphic Transformations
26 * @author Nicola Asuni
27 * @since 2008-03-04
28 */
29
30require_once('../config/lang/eng.php');
31require_once('../tcpdf.php');
32
33// create new PDF document
34$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
35
36// set document information
37$pdf->SetCreator(PDF_CREATOR);
38$pdf->SetAuthor('Nicola Asuni');
39$pdf->SetTitle('TCPDF Example 013');
40$pdf->SetSubject('TCPDF Tutorial');
41$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
42
43// set default header data
44$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 013', PDF_HEADER_STRING);
45
46// set header and footer fonts
47$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
48$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
49
50// set default monospaced font
51$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
52
53//set margins
54$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
55$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
56$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
57
58//set auto page breaks
59$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
60
61//set image scale factor
62$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
63
64//set some language-dependent strings
65$pdf->setLanguageArray($l);
66
67// ---------------------------------------------------------
68
69// set font
70$pdf->SetFont('helvetica', 'B', 20);
71
72// add a page
73$pdf->AddPage();
74
75$pdf->Write(0, 'Graphic Transformations', '', 0, 'C', 1, 0, false, false, 0);
76
77// set font
78$pdf->SetFont('helvetica', '', 10);
79
80// --- Scaling ---------------------------------------------
81$pdf->SetDrawColor(200);
82$pdf->SetTextColor(200);
83$pdf->Rect(50, 70, 40, 10, 'D');
84$pdf->Text(50, 66, 'Scale');
85$pdf->SetDrawColor(0);
86$pdf->SetTextColor(0);
87// Start Transformation
88$pdf->StartTransform();
89// Scale by 150% centered by (50,80) which is the lower left corner of the rectangle
90$pdf->ScaleXY(150, 50, 80);
91$pdf->Rect(50, 70, 40, 10, 'D');
92$pdf->Text(50, 66, 'Scale');
93// Stop Transformation
94$pdf->StopTransform();
95
96// --- Translation -----------------------------------------
97$pdf->SetDrawColor(200);
98$pdf->SetTextColor(200);
99$pdf->Rect(125, 70, 40, 10, 'D');
100$pdf->Text(125, 66, 'Translate');
101$pdf->SetDrawColor(0);
102$pdf->SetTextColor(0);
103// Start Transformation
104$pdf->StartTransform();
105// Translate 7 to the right, 5 to the bottom
106$pdf->Translate(7, 5);
107$pdf->Rect(125, 70, 40, 10, 'D');
108$pdf->Text(125, 66, 'Translate');
109// Stop Transformation
110$pdf->StopTransform();
111
112// --- Rotation --------------------------------------------
113$pdf->SetDrawColor(200);
114$pdf->SetTextColor(200);
115$pdf->Rect(70, 100, 40, 10, 'D');
116$pdf->Text(70, 96, 'Rotate');
117$pdf->SetDrawColor(0);
118$pdf->SetTextColor(0);
119// Start Transformation
120$pdf->StartTransform();
121// Rotate 20 degrees counter-clockwise centered by (70,110) which is the lower left corner of the rectangle
122$pdf->Rotate(20, 70, 110);
123$pdf->Rect(70, 100, 40, 10, 'D');
124$pdf->Text(70, 96, 'Rotate');
125// Stop Transformation
126$pdf->StopTransform();
127
128// --- Skewing ---------------------------------------------
129$pdf->SetDrawColor(200);
130$pdf->SetTextColor(200);
131$pdf->Rect(125, 100, 40, 10, 'D');
132$pdf->Text(125, 96, 'Skew');
133$pdf->SetDrawColor(0);
134$pdf->SetTextColor(0);
135// Start Transformation
136$pdf->StartTransform();
137// skew 30 degrees along the x-axis centered by (125,110) which is the lower left corner of the rectangle
138$pdf->SkewX(30, 125, 110);
139$pdf->Rect(125, 100, 40, 10, 'D');
140$pdf->Text(125, 96, 'Skew');
141// Stop Transformation
142$pdf->StopTransform();
143
144// --- Mirroring horizontally ------------------------------
145$pdf->SetDrawColor(200);
146$pdf->SetTextColor(200);
147$pdf->Rect(70, 130, 40, 10, 'D');
148$pdf->Text(70, 126, 'MirrorH');
149$pdf->SetDrawColor(0);
150$pdf->SetTextColor(0);
151// Start Transformation
152$pdf->StartTransform();
153// mirror horizontally with axis of reflection at x-position 70 (left side of the rectangle)
154$pdf->MirrorH(70);
155$pdf->Rect(70, 130, 40, 10, 'D');
156$pdf->Text(70, 126, 'MirrorH');
157// Stop Transformation
158$pdf->StopTransform();
159
160// --- Mirroring vertically --------------------------------
161$pdf->SetDrawColor(200);
162$pdf->SetTextColor(200);
163$pdf->Rect(125, 130, 40, 10, 'D');
164$pdf->Text(125, 126, 'MirrorV');
165$pdf->SetDrawColor(0);
166$pdf->SetTextColor(0);
167// Start Transformation
168$pdf->StartTransform();
169// mirror vertically with axis of reflection at y-position 140 (bottom side of the rectangle)
170$pdf->MirrorV(140);
171$pdf->Rect(125, 130, 40, 10, 'D');
172$pdf->Text(125, 126, 'MirrorV');
173// Stop Transformation
174$pdf->StopTransform();
175
176// --- Point reflection ------------------------------------
177$pdf->SetDrawColor(200);
178$pdf->SetTextColor(200);
179$pdf->Rect(70, 160, 40, 10, 'D');
180$pdf->Text(70, 156, 'MirrorP');
181$pdf->SetDrawColor(0);
182$pdf->SetTextColor(0);
183// Start Transformation
184$pdf->StartTransform();
185// point reflection at the lower left point of rectangle
186$pdf->MirrorP(70,170);
187$pdf->Rect(70, 160, 40, 10, 'D');
188$pdf->Text(70, 156, 'MirrorP');
189// Stop Transformation
190$pdf->StopTransform();
191
192// --- Mirroring against a straigth line described by a point (120, 120) and an angle -20°
193$angle=-20;
194$px=120;
195$py=170;
196
197// just for visualisation: the straight line to mirror against
198
199$pdf->SetDrawColor(200);
200$pdf->Line($px-1,$py-1,$px+1,$py+1);
201$pdf->Line($px-1,$py+1,$px+1,$py-1);
202$pdf->StartTransform();
203$pdf->Rotate($angle, $px, $py);
204$pdf->Line($px-5, $py, $px+60, $py);
205$pdf->StopTransform();
206
207$pdf->SetDrawColor(200);
208$pdf->SetTextColor(200);
209$pdf->Rect(125, 160, 40, 10, 'D');
210$pdf->Text(125, 156, 'MirrorL');
211$pdf->SetDrawColor(0);
212$pdf->SetTextColor(0);
213//Start Transformation
214$pdf->StartTransform();
215//mirror against the straight line
216$pdf->MirrorL($angle, $px, $py);
217$pdf->Rect(125, 160, 40, 10, 'D');
218$pdf->Text(125, 156, 'MirrorL');
219//Stop Transformation
220$pdf->StopTransform();
221
222// ---------------------------------------------------------
223
224//Close and output PDF document
225$pdf->Output('example_013.pdf', 'I');
226
227//============================================================+
228// END OF FILE
229//============================================================+
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.