Subversion Repositories Applications.annuaire

Rev

Rev 296 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
296 aurelien 1
<?php
2
//============================================================+
3
// File name   : example_027.php
4
// Begin       : 2008-03-04
5
// Last Update : 2010-10-21
6
//
7
// Description : Example 027 for TCPDF class
8
//               1D 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: 1D 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 027');
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.' 027', 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
// set a barcode on the page footer
73
$pdf->setBarcode(date('Y-m-d H:i:s'));
74
 
75
// set font
76
$pdf->SetFont('helvetica', '', 10);
77
 
78
// add a page
79
$pdf->AddPage();
80
 
81
// define barcode style
82
$style = array(
83
	'position' => '',
84
	'align' => 'C',
85
	'stretch' => false,
86
	'fitwidth' => true,
87
	'cellfitalign' => '',
88
	'border' => true,
89
	'hpadding' => 'auto',
90
	'vpadding' => 'auto',
91
	'fgcolor' => array(0,0,0),
92
	'bgcolor' => false, //array(255,255,255),
93
	'text' => true,
94
	'font' => 'helvetica',
95
	'fontsize' => 8,
96
	'stretchtext' => 4
97
);
98
 
99
// PRINT VARIOUS 1D BARCODES
100
 
101
// CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
102
$pdf->Cell(0, 0, 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9', 0, 1);
103
$pdf->write1DBarcode('CODE 39', 'C39', '', '', '', 18, 0.4, $style, 'N');
104
 
105
$pdf->Ln();
106
 
107
// CODE 39 + CHECKSUM
108
$pdf->Cell(0, 0, 'CODE 39 + CHECKSUM', 0, 1);
109
$pdf->write1DBarcode('CODE 39 +', 'C39+', '', '', '', 18, 0.4, $style, 'N');
110
 
111
$pdf->Ln();
112
 
113
// CODE 39 EXTENDED
114
$pdf->Cell(0, 0, 'CODE 39 EXTENDED', 0, 1);
115
$pdf->write1DBarcode('CODE 39 E', 'C39E', '', '', '', 18, 0.4, $style, 'N');
116
 
117
$pdf->Ln();
118
 
119
// CODE 39 EXTENDED + CHECKSUM
120
$pdf->Cell(0, 0, 'CODE 39 EXTENDED + CHECKSUM', 0, 1);
121
$pdf->write1DBarcode('CODE 39 E+', 'C39E+', '', '', '', 18, 0.4, $style, 'N');
122
 
123
$pdf->Ln();
124
 
125
// CODE 93 - USS-93
126
$pdf->Cell(0, 0, 'CODE 93 - USS-93', 0, 1);
127
$pdf->write1DBarcode('TEST93', 'C93', '', '', '', 18, 0.4, $style, 'N');
128
 
129
$pdf->Ln();
130
 
131
// Standard 2 of 5
132
$pdf->Cell(0, 0, 'Standard 2 of 5', 0, 1);
133
$pdf->write1DBarcode('1234567', 'S25', '', '', '', 18, 0.4, $style, 'N');
134
 
135
$pdf->Ln();
136
 
137
// Standard 2 of 5 + CHECKSUM
138
$pdf->Cell(0, 0, 'Standard 2 of 5 + CHECKSUM', 0, 1);
139
$pdf->write1DBarcode('1234567', 'S25+', '', '', '', 18, 0.4, $style, 'N');
140
 
141
$pdf->Ln();
142
 
143
// Interleaved 2 of 5
144
$pdf->Cell(0, 0, 'Interleaved 2 of 5', 0, 1);
145
$pdf->write1DBarcode('1234567', 'I25', '', '', '', 18, 0.4, $style, 'N');
146
 
147
$pdf->Ln();
148
 
149
// Interleaved 2 of 5 + CHECKSUM
150
$pdf->Cell(0, 0, 'Interleaved 2 of 5 + CHECKSUM', 0, 1);
151
$pdf->write1DBarcode('1234567', 'I25+', '', '', '', 18, 0.4, $style, 'N');
152
 
153
 
154
// add a page ----------
155
$pdf->AddPage();
156
 
157
// CODE 128 A
158
$pdf->Cell(0, 0, 'CODE 128 A', 0, 1);
159
$pdf->write1DBarcode('CODE 128 A', 'C128A', '', '', '', 18, 0.4, $style, 'N');
160
 
161
$pdf->Ln();
162
 
163
// CODE 128 B
164
$pdf->Cell(0, 0, 'CODE 128 B', 0, 1);
165
$pdf->write1DBarcode('CODE 128 B', 'C128B', '', '', '', 18, 0.4, $style, 'N');
166
 
167
$pdf->Ln();
168
 
169
// CODE 128 C
170
$pdf->Cell(0, 0, 'CODE 128 C', 0, 1);
171
$pdf->write1DBarcode('0123456789', 'C128C', '', '', '', 18, 0.4, $style, 'N');
172
 
173
$pdf->Ln();
174
 
175
// EAN 8
176
$pdf->Cell(0, 0, 'EAN 8', 0, 1);
177
$pdf->write1DBarcode('1234567', 'EAN8', '', '', '', 18, 0.4, $style, 'N');
178
 
179
$pdf->Ln();
180
 
181
// EAN 13
182
$pdf->Cell(0, 0, 'EAN 13', 0, 1);
183
$pdf->write1DBarcode('1234567890128', 'EAN13', '', '', '', 18, 0.4, $style, 'N');
184
 
185
$pdf->Ln();
186
 
187
// UPC-A
188
$pdf->Cell(0, 0, 'UPC-A', 0, 1);
189
$pdf->write1DBarcode('12345678901', 'UPCA', '', '', '', 18, 0.4, $style, 'N');
190
 
191
$pdf->Ln();
192
 
193
// UPC-E
194
$pdf->Cell(0, 0, 'UPC-E', 0, 1);
195
$pdf->write1DBarcode('04210000526', 'UPCE', '', '', '', 18, 0.4, $style, 'N');
196
 
197
$pdf->Ln();
198
 
199
// 5-Digits UPC-Based Extention
200
$pdf->Cell(0, 0, '5-Digits UPC-Based Extention', 0, 1);
201
$pdf->write1DBarcode('51234', 'EAN5', '', '', '', 18, 0.4, $style, 'N');
202
 
203
$pdf->Ln();
204
 
205
// 2-Digits UPC-Based Extention
206
$pdf->Cell(0, 0, '2-Digits UPC-Based Extention', 0, 1);
207
$pdf->write1DBarcode('34', 'EAN2', '', '', '', 18, 0.4, $style, 'N');
208
 
209
// add a page ----------
210
$pdf->AddPage();
211
 
212
// MSI
213
$pdf->Cell(0, 0, 'MSI', 0, 1);
214
$pdf->write1DBarcode('80523', 'MSI', '', '', '', 18, 0.4, $style, 'N');
215
 
216
$pdf->Ln();
217
 
218
// MSI + CHECKSUM (module 11)
219
$pdf->Cell(0, 0, 'MSI + CHECKSUM (module 11)', 0, 1);
220
$pdf->write1DBarcode('80523', 'MSI+', '', '', '', 18, 0.4, $style, 'N');
221
 
222
$pdf->Ln();
223
 
224
// CODABAR
225
$pdf->Cell(0, 0, 'CODABAR', 0, 1);
226
$pdf->write1DBarcode('123456789', 'CODABAR', '', '', '', 18, 0.4, $style, 'N');
227
 
228
$pdf->Ln();
229
 
230
// CODE 11
231
$pdf->Cell(0, 0, 'CODE 11', 0, 1);
232
$pdf->write1DBarcode('123-456-789', 'CODE11', '', '', '', 18, 0.4, $style, 'N');
233
 
234
$pdf->Ln();
235
 
236
// PHARMACODE
237
$pdf->Cell(0, 0, 'PHARMACODE', 0, 1);
238
$pdf->write1DBarcode('789', 'PHARMA', '', '', '', 18, 0.4, $style, 'N');
239
 
240
$pdf->Ln();
241
 
242
// PHARMACODE TWO-TRACKS
243
$pdf->Cell(0, 0, 'PHARMACODE TWO-TRACKS', 0, 1);
244
$pdf->write1DBarcode('105', 'PHARMA2T', '', '', '', 18, 2, $style, 'N');
245
 
246
// add a page ----------
247
$pdf->AddPage();
248
 
249
// IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
250
$pdf->Cell(0, 0, 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', 0, 1);
251
$pdf->write1DBarcode('01234567094987654321-01234567891', 'IMB', '', '', '', 15, 0.6, $style, 'N');
252
 
253
$pdf->Ln();
254
 
255
// POSTNET
256
$pdf->Cell(0, 0, 'POSTNET', 0, 1);
257
$pdf->write1DBarcode('98000', 'POSTNET', '', '', '', 15, 0.6, $style, 'N');
258
 
259
$pdf->Ln();
260
 
261
// PLANET
262
$pdf->Cell(0, 0, 'PLANET', 0, 1);
263
$pdf->write1DBarcode('98000', 'PLANET', '', '', '', 15, 0.6, $style, 'N');
264
 
265
$pdf->Ln();
266
 
267
// RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
268
$pdf->Cell(0, 0, 'RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)', 0, 1);
269
$pdf->write1DBarcode('SN34RD1A', 'RMS4CC', '', '', '', 15, 0.6, $style, 'N');
270
 
271
$pdf->Ln();
272
 
273
// KIX (Klant index - Customer index)
274
$pdf->Cell(0, 0, 'KIX (Klant index - Customer index)', 0, 1);
275
$pdf->write1DBarcode('SN34RDX1A', 'KIX', '', '', '', 15, 0.6, $style, 'N');
276
 
277
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
278
// TEST BARCODE ALIGNMENTS
279
 
280
// add a page
281
$pdf->AddPage();
282
 
283
// set a background color
284
$style['bgcolor'] = array(255,255,240);
285
$style['fgcolor'] = array(127,0,0);
286
 
287
// Left position
288
$style['position'] = 'L';
289
$pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
290
 
291
$pdf->Ln(2);
292
 
293
// Center position
294
$style['position'] = 'C';
295
$pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N');
296
 
297
$pdf->Ln(2);
298
 
299
// Right position
300
$style['position'] = 'R';
301
$pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
302
 
303
$pdf->Ln(2);
304
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
305
 
306
$style['fgcolor'] = array(0,127,0);
307
$style['position'] = '';
308
$style['stretch'] = false; // disable stretch
309
$style['fitwidth'] = false; // disable fitwidth
310
 
311
// Left alignment
312
$style['align'] = 'L';
313
$pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
314
 
315
$pdf->Ln(2);
316
 
317
// Center alignment
318
$style['align'] = 'C';
319
$pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N');
320
 
321
$pdf->Ln(2);
322
 
323
// Right alignment
324
$style['align'] = 'R';
325
$pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
326
 
327
$pdf->Ln(2);
328
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
329
 
330
$style['fgcolor'] = array(0,64,127);
331
$style['position'] = '';
332
$style['stretch'] = false; // disable stretch
333
$style['fitwidth'] = true; // disable fitwidth
334
 
335
// Left alignment
336
$style['cellfitalign'] = 'L';
337
$pdf->write1DBarcode('LEFT', 'C128A', 105, '', 90, 15, 0.4, $style, 'N');
338
 
339
$pdf->Ln(2);
340
 
341
// Center alignment
342
$style['cellfitalign'] = 'C';
343
$pdf->write1DBarcode('CENTER', 'C128A', 105, '', 90, 15, 0.4, $style, 'N');
344
 
345
$pdf->Ln(2);
346
 
347
// Right alignment
348
$style['cellfitalign'] = 'R';
349
$pdf->write1DBarcode('RIGHT', 'C128A', 105, '', 90, 15, 0.4, $style, 'N');
350
 
351
$pdf->Ln(2);
352
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
353
 
354
$style['fgcolor'] = array(127,0,127);
355
 
356
// Left alignment
357
$style['position'] = 'L';
358
$pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
359
 
360
$pdf->Ln(2);
361
 
362
// Center alignment
363
$style['position'] = 'C';
364
$pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N');
365
 
366
$pdf->Ln(2);
367
 
368
// Right alignment
369
$style['position'] = 'R';
370
$pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
371
 
372
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
373
// TEST BARCODE STYLE
374
 
375
// define barcode style
376
$style = array(
377
	'position' => '',
378
	'align' => '',
379
	'stretch' => true,
380
	'fitwidth' => false,
381
	'cellfitalign' => '',
382
	'border' => true,
383
	'hpadding' => 'auto',
384
	'vpadding' => 'auto',
385
	'fgcolor' => array(0,0,128),
386
	'bgcolor' => array(255,255,128),
387
	'text' => true,
388
	'label' => 'CUSTOM LABEL',
389
	'font' => 'helvetica',
390
	'fontsize' => 8,
391
	'stretchtext' => 4
392
);
393
 
394
// CODE 39 EXTENDED + CHECKSUM
395
$pdf->Cell(0, 0, 'CODE 39 EXTENDED + CHECKSUM', 0, 1);
396
$pdf->SetLineStyle(array('width' => 1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0)));
397
$pdf->write1DBarcode('CODE 39 E+', 'C39E+', '', '', 120, 25, 0.4, $style, 'N');
398
 
399
// ---------------------------------------------------------
400
 
401
//Close and output PDF document
402
$pdf->Output('example_027.pdf', 'I');
403
 
404
//============================================================+
405
// END OF FILE
406
//============================================================+