Subversion Repositories Applications.annuaire

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
296 aurelien 1
<?php
2
//============================================================+
3
// File name   : example_050.php
4
// Begin       : 2009-04-09
5
// Last Update : 2010-08-08
6
//
7
// Description : Example 050 for TCPDF class
8
//               2D Barcodes
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: 2D barcodes.
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 2008-03-04
31
 */
32
 
33
require_once('../config/lang/eng.php');
34
require_once('../tcpdf.php');
35
 
36
// create new PDF document
37
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
38
 
39
// set document information
40
$pdf->SetCreator(PDF_CREATOR);
41
$pdf->SetAuthor('Nicola Asuni');
42
$pdf->SetTitle('TCPDF Example 050');
43
$pdf->SetSubject('TCPDF Tutorial');
44
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
45
 
46
// set default header data
47
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 050', PDF_HEADER_STRING);
48
 
49
// set header and footer fonts
50
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
51
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
52
 
53
// set default monospaced font
54
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
55
 
56
//set margins
57
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
58
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
59
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
60
 
61
//set auto page breaks
62
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
63
 
64
//set image scale factor
65
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
66
 
67
//set some language-dependent strings
68
$pdf->setLanguageArray($l);
69
 
70
// ---------------------------------------------------------
71
 
72
// NOTE: 2D barcode algorithms must be implemented on 2dbarcode.php class file.
73
 
74
// set font
75
$pdf->SetFont('helvetica', '', 10);
76
 
77
// add a page
78
$pdf->AddPage();
79
 
80
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81
 
82
// set style for barcode
83
$style = array(
84
	'border' => true,
85
	'vpadding' => 'auto',
86
	'hpadding' => 'auto',
87
	'fgcolor' => array(0,0,0),
88
	'bgcolor' => false, //array(255,255,255)
89
	'module_width' => 1, // width of a single module in points
90
	'module_height' => 1 // height of a single module in points
91
);
92
 
93
// write RAW 2D Barcode
94
$pdf->SetXY(30, 30);
95
$code = '111011101110111,010010001000010,010011001110010,010010000010010,010011101110010';
96
$pdf->write2DBarcode($code, 'RAW', '', '', 30, 20, $style, 'N');
97
 
98
$pdf->SetXY(100, 30);
99
// write RAW2 2D Barcode
100
$code = '[111011101110111][010010001000010][010011001110010][010010000010010][010011101110010]';
101
$pdf->write2DBarcode($code, 'RAW2', '', '', 30, 20, $style, 'N');
102
 
103
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104
 
105
// set style for barcode
106
$style = array(
107
	'border' => 2,
108
	'vpadding' => 'auto',
109
	'hpadding' => 'auto',
110
	'fgcolor' => array(0,0,0),
111
	'bgcolor' => false, //array(255,255,255)
112
	'module_width' => 1, // width of a single module in points
113
	'module_height' => 1 // height of a single module in points
114
);
115
 
116
// QRCODE,L : QR-CODE Low error correction
117
$pdf->SetXY(30, 60);
118
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,L', '', '', 50, 50, $style, 'N');
119
$pdf->Text(30, 55, 'QRCODE L');
120
 
121
// QRCODE,M : QR-CODE Medium error correction
122
$pdf->SetXY(100, 60);
123
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,M', '', '', 50, 50, $style, 'N');
124
$pdf->Text(100, 55, 'QRCODE M');
125
 
126
// QRCODE,Q : QR-CODE Better error correction
127
$pdf->SetXY(30, 120);
128
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,Q', '', '', 50, 50, $style, 'N');
129
$pdf->Text(30, 115, 'QRCODE Q');
130
 
131
 
132
// QRCODE,H : QR-CODE Best error correction
133
$pdf->SetXY(100, 120);
134
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', '', '', 50, 50, $style, 'N');
135
$pdf->Text(100, 115, 'QRCODE H');
136
 
137
// -------------------------------------------------------------------
138
// PDF417 (ISO/IEC 15438:2006)
139
 
140
/*
141
 
142
 The $type parameter can be simple 'PDF417' or 'PDF417' followed by a
143
 number of comma-separated options:
144
 
145
 'PDF417,a,e,t,s,f,o0,o1,o2,o3,o4,o5,o6'
146
 
147
 Possible options are:
148
 
149
 	a  = aspect ratio (width/height);
150
 	e  = error correction level (0-8);
151
 
152
 	Macro Control Block options:
153
 
154
 	t  = total number of macro segments;
155
 	s  = macro segment index (0-99998);
156
 	f  = file ID;
157
 	o0 = File Name (text);
158
 	o1 = Segment Count (numeric);
159
 	o2 = Time Stamp (numeric);
160
 	o3 = Sender (text);
161
 	o4 = Addressee (text);
162
 	o5 = File Size (numeric);
163
 	o6 = Checksum (numeric).
164
 
165
 Parameters t, s and f are required for a Macro Control Block, all other parametrs are optional.
166
 To use a comma character ',' on text options, replace it with the character 255: "\xff".
167
 
168
*/
169
 
170
$pdf->SetXY(30, 180);
171
$pdf->write2DBarcode('www.tcpdf.org', 'PDF417', '', '', 0, 30, $style, 'N');
172
$pdf->Text(30, 175, 'PDF417 (ISO/IEC 15438:2006)');
173
 
174
// -------------------------------------------------------------------
175
// new style
176
$style = array(
177
	'border' => 2,
178
	'padding' => 'auto',
179
	'fgcolor' => array(0,0,255),
180
	'bgcolor' => array(255,255,64)
181
);
182
 
183
// QRCODE,H : QR-CODE Best error correction
184
$pdf->SetXY(30, 220);
185
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', '', '', 50, 50, $style, 'N');
186
$pdf->Text(30, 215, 'QRCODE H - COLORED');
187
 
188
// new style
189
$style = array(
190
	'border' => false,
191
	'padding' => 0,
192
	'fgcolor' => array(128,0,0),
193
	'bgcolor' => false
194
);
195
 
196
// QRCODE,H : QR-CODE Best error correction
197
$pdf->SetXY(100, 220);
198
$pdf->write2DBarcode('www.tcpdf.org', 'QRCODE,H', '', '', 50, 50, $style, 'N');
199
$pdf->Text(100, 215, 'QRCODE H - NO PADDING');
200
 
201
// ---------------------------------------------------------
202
 
203
//Close and output PDF document
204
$pdf->Output('example_050.pdf', 'I');
205
 
206
//============================================================+
207
// END OF FILE
208
//============================================================+