couple very minor fixes to prior commit
[openemr.git] / library / html2pdf / vendor / tecnickcom / tcpdf / examples / example_027.php
bloba23707451a85bafe8afb1287a418a2a5a3b61a8e
1 <?php
2 //============================================================+
3 // File name : example_027.php
4 // Begin : 2008-03-04
5 // Last Update : 2013-05-14
6 //
7 // Description : Example 027 for TCPDF class
8 // 1D Barcodes
9 //
10 // Author: Nicola Asuni
12 // (c) Copyright:
13 // Nicola Asuni
14 // Tecnick.com LTD
15 // www.tecnick.com
16 // info@tecnick.com
17 //============================================================+
19 /**
20 * Creates an example PDF TEST document using TCPDF
21 * @package com.tecnick.tcpdf
22 * @abstract TCPDF - Example: 1D Barcodes.
23 * @author Nicola Asuni
24 * @since 2008-03-04
27 // Include the main TCPDF library (search for installation path).
28 require_once('tcpdf_include.php');
30 // create new PDF document
31 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
33 // set document information
34 $pdf->SetCreator(PDF_CREATOR);
35 $pdf->SetAuthor('Nicola Asuni');
36 $pdf->SetTitle('TCPDF Example 027');
37 $pdf->SetSubject('TCPDF Tutorial');
38 $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
40 // set default header data
41 $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 027', PDF_HEADER_STRING);
43 // set header and footer fonts
44 $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
45 $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
47 // set default monospaced font
48 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
50 // set margins
51 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
52 $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
53 $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
55 // set auto page breaks
56 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
58 // set image scale factor
59 $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
61 // set some language-dependent strings (optional)
62 if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
63 require_once(dirname(__FILE__).'/lang/eng.php');
64 $pdf->setLanguageArray($l);
67 // ---------------------------------------------------------
69 // set a barcode on the page footer
70 $pdf->setBarcode(date('Y-m-d H:i:s'));
72 // set font
73 $pdf->SetFont('helvetica', '', 11);
75 // add a page
76 $pdf->AddPage();
78 // print a message
79 $txt = "You can also export 1D barcodes in other formats (PNG, SVG, HTML). Check the examples inside the barcodes directory.\n";
80 $pdf->MultiCell(70, 50, $txt, 0, 'J', false, 1, 125, 30, true, 0, false, true, 0, 'T', false);
81 $pdf->SetY(30);
83 // -----------------------------------------------------------------------------
85 $pdf->SetFont('helvetica', '', 10);
87 // define barcode style
88 $style = array(
89 'position' => '',
90 'align' => 'C',
91 'stretch' => false,
92 'fitwidth' => true,
93 'cellfitalign' => '',
94 'border' => true,
95 'hpadding' => 'auto',
96 'vpadding' => 'auto',
97 'fgcolor' => array(0,0,0),
98 'bgcolor' => false, //array(255,255,255),
99 'text' => true,
100 'font' => 'helvetica',
101 'fontsize' => 8,
102 'stretchtext' => 4
105 // PRINT VARIOUS 1D BARCODES
107 // CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
108 $pdf->Cell(0, 0, 'CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9', 0, 1);
109 $pdf->write1DBarcode('CODE 39', 'C39', '', '', '', 18, 0.4, $style, 'N');
111 $pdf->Ln();
113 // CODE 39 + CHECKSUM
114 $pdf->Cell(0, 0, 'CODE 39 + CHECKSUM', 0, 1);
115 $pdf->write1DBarcode('CODE 39 +', 'C39+', '', '', '', 18, 0.4, $style, 'N');
117 $pdf->Ln();
119 // CODE 39 EXTENDED
120 $pdf->Cell(0, 0, 'CODE 39 EXTENDED', 0, 1);
121 $pdf->write1DBarcode('CODE 39 E', 'C39E', '', '', '', 18, 0.4, $style, 'N');
123 $pdf->Ln();
125 // CODE 39 EXTENDED + CHECKSUM
126 $pdf->Cell(0, 0, 'CODE 39 EXTENDED + CHECKSUM', 0, 1);
127 $pdf->write1DBarcode('CODE 39 E+', 'C39E+', '', '', '', 18, 0.4, $style, 'N');
129 $pdf->Ln();
131 // CODE 93 - USS-93
132 $pdf->Cell(0, 0, 'CODE 93 - USS-93', 0, 1);
133 $pdf->write1DBarcode('TEST93', 'C93', '', '', '', 18, 0.4, $style, 'N');
135 $pdf->Ln();
137 // Standard 2 of 5
138 $pdf->Cell(0, 0, 'Standard 2 of 5', 0, 1);
139 $pdf->write1DBarcode('1234567', 'S25', '', '', '', 18, 0.4, $style, 'N');
141 $pdf->Ln();
143 // Standard 2 of 5 + CHECKSUM
144 $pdf->Cell(0, 0, 'Standard 2 of 5 + CHECKSUM', 0, 1);
145 $pdf->write1DBarcode('1234567', 'S25+', '', '', '', 18, 0.4, $style, 'N');
147 $pdf->Ln();
149 // Interleaved 2 of 5
150 $pdf->Cell(0, 0, 'Interleaved 2 of 5', 0, 1);
151 $pdf->write1DBarcode('1234567', 'I25', '', '', '', 18, 0.4, $style, 'N');
153 $pdf->Ln();
155 // Interleaved 2 of 5 + CHECKSUM
156 $pdf->Cell(0, 0, 'Interleaved 2 of 5 + CHECKSUM', 0, 1);
157 $pdf->write1DBarcode('1234567', 'I25+', '', '', '', 18, 0.4, $style, 'N');
160 // add a page ----------
161 $pdf->AddPage();
163 // CODE 128 AUTO
164 $pdf->Cell(0, 0, 'CODE 128 AUTO', 0, 1);
165 $pdf->write1DBarcode('CODE 128 AUTO', 'C128', '', '', '', 18, 0.4, $style, 'N');
167 $pdf->Ln();
169 // CODE 128 A
170 $pdf->Cell(0, 0, 'CODE 128 A', 0, 1);
171 $pdf->write1DBarcode('CODE 128 A', 'C128A', '', '', '', 18, 0.4, $style, 'N');
173 $pdf->Ln();
175 // CODE 128 B
176 $pdf->Cell(0, 0, 'CODE 128 B', 0, 1);
177 $pdf->write1DBarcode('CODE 128 B', 'C128B', '', '', '', 18, 0.4, $style, 'N');
179 $pdf->Ln();
181 // CODE 128 C
182 $pdf->Cell(0, 0, 'CODE 128 C', 0, 1);
183 $pdf->write1DBarcode('0123456789', 'C128C', '', '', '', 18, 0.4, $style, 'N');
185 $pdf->Ln();
187 // EAN 8
188 $pdf->Cell(0, 0, 'EAN 8', 0, 1);
189 $pdf->write1DBarcode('1234567', 'EAN8', '', '', '', 18, 0.4, $style, 'N');
191 $pdf->Ln();
193 // EAN 13
194 $pdf->Cell(0, 0, 'EAN 13', 0, 1);
195 $pdf->write1DBarcode('1234567890128', 'EAN13', '', '', '', 18, 0.4, $style, 'N');
197 $pdf->Ln();
199 // UPC-A
200 $pdf->Cell(0, 0, 'UPC-A', 0, 1);
201 $pdf->write1DBarcode('12345678901', 'UPCA', '', '', '', 18, 0.4, $style, 'N');
203 $pdf->Ln();
205 // UPC-E
206 $pdf->Cell(0, 0, 'UPC-E', 0, 1);
207 $pdf->write1DBarcode('04210000526', 'UPCE', '', '', '', 18, 0.4, $style, 'N');
209 // add a page ----------
210 $pdf->AddPage();
212 // 5-Digits UPC-Based Extension
213 $pdf->Cell(0, 0, '5-Digits UPC-Based Extension', 0, 1);
214 $pdf->write1DBarcode('51234', 'EAN5', '', '', '', 18, 0.4, $style, 'N');
216 $pdf->Ln();
218 // 2-Digits UPC-Based Extension
219 $pdf->Cell(0, 0, '2-Digits UPC-Based Extension', 0, 1);
220 $pdf->write1DBarcode('34', 'EAN2', '', '', '', 18, 0.4, $style, 'N');
222 $pdf->Ln();
224 // MSI
225 $pdf->Cell(0, 0, 'MSI', 0, 1);
226 $pdf->write1DBarcode('80523', 'MSI', '', '', '', 18, 0.4, $style, 'N');
228 $pdf->Ln();
230 // MSI + CHECKSUM (module 11)
231 $pdf->Cell(0, 0, 'MSI + CHECKSUM (module 11)', 0, 1);
232 $pdf->write1DBarcode('80523', 'MSI+', '', '', '', 18, 0.4, $style, 'N');
234 $pdf->Ln();
236 // CODABAR
237 $pdf->Cell(0, 0, 'CODABAR', 0, 1);
238 $pdf->write1DBarcode('123456789', 'CODABAR', '', '', '', 18, 0.4, $style, 'N');
240 $pdf->Ln();
242 // CODE 11
243 $pdf->Cell(0, 0, 'CODE 11', 0, 1);
244 $pdf->write1DBarcode('123-456-789', 'CODE11', '', '', '', 18, 0.4, $style, 'N');
246 $pdf->Ln();
248 // PHARMACODE
249 $pdf->Cell(0, 0, 'PHARMACODE', 0, 1);
250 $pdf->write1DBarcode('789', 'PHARMA', '', '', '', 18, 0.4, $style, 'N');
252 $pdf->Ln();
254 // PHARMACODE TWO-TRACKS
255 $pdf->Cell(0, 0, 'PHARMACODE TWO-TRACKS', 0, 1);
256 $pdf->write1DBarcode('105', 'PHARMA2T', '', '', '', 18, 2, $style, 'N');
258 // add a page ----------
259 $pdf->AddPage();
261 // IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
262 $pdf->Cell(0, 0, 'IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200', 0, 1);
263 $pdf->write1DBarcode('01234567094987654321-01234567891', 'IMB', '', '', '', 15, 0.6, $style, 'N');
265 $pdf->Ln();
267 // POSTNET
268 $pdf->Cell(0, 0, 'POSTNET', 0, 1);
269 $pdf->write1DBarcode('98000', 'POSTNET', '', '', '', 15, 0.6, $style, 'N');
271 $pdf->Ln();
273 // PLANET
274 $pdf->Cell(0, 0, 'PLANET', 0, 1);
275 $pdf->write1DBarcode('98000', 'PLANET', '', '', '', 15, 0.6, $style, 'N');
277 $pdf->Ln();
279 // RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
280 $pdf->Cell(0, 0, 'RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)', 0, 1);
281 $pdf->write1DBarcode('SN34RD1A', 'RMS4CC', '', '', '', 15, 0.6, $style, 'N');
283 $pdf->Ln();
285 // KIX (Klant index - Customer index)
286 $pdf->Cell(0, 0, 'KIX (Klant index - Customer index)', 0, 1);
287 $pdf->write1DBarcode('SN34RDX1A', 'KIX', '', '', '', 15, 0.6, $style, 'N');
289 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
290 // TEST BARCODE ALIGNMENTS
292 // add a page
293 $pdf->AddPage();
295 // set a background color
296 $style['bgcolor'] = array(255,255,240);
297 $style['fgcolor'] = array(127,0,0);
299 // Left position
300 $style['position'] = 'L';
301 $pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
303 $pdf->Ln(2);
305 // Center position
306 $style['position'] = 'C';
307 $pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N');
309 $pdf->Ln(2);
311 // Right position
312 $style['position'] = 'R';
313 $pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
315 $pdf->Ln(2);
316 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
318 $style['fgcolor'] = array(0,127,0);
319 $style['position'] = '';
320 $style['stretch'] = false; // disable stretch
321 $style['fitwidth'] = false; // disable fitwidth
323 // Left alignment
324 $style['align'] = 'L';
325 $pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
327 $pdf->Ln(2);
329 // Center alignment
330 $style['align'] = 'C';
331 $pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N');
333 $pdf->Ln(2);
335 // Right alignment
336 $style['align'] = 'R';
337 $pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
339 $pdf->Ln(2);
340 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
342 $style['fgcolor'] = array(0,64,127);
343 $style['position'] = '';
344 $style['stretch'] = false; // disable stretch
345 $style['fitwidth'] = true; // disable fitwidth
347 // Left alignment
348 $style['cellfitalign'] = 'L';
349 $pdf->write1DBarcode('LEFT', 'C128A', 105, '', 90, 15, 0.4, $style, 'N');
351 $pdf->Ln(2);
353 // Center alignment
354 $style['cellfitalign'] = 'C';
355 $pdf->write1DBarcode('CENTER', 'C128A', 105, '', 90, 15, 0.4, $style, 'N');
357 $pdf->Ln(2);
359 // Right alignment
360 $style['cellfitalign'] = 'R';
361 $pdf->write1DBarcode('RIGHT', 'C128A', 105, '', 90, 15, 0.4, $style, 'N');
363 $pdf->Ln(2);
364 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
366 $style['fgcolor'] = array(127,0,127);
368 // Left alignment
369 $style['position'] = 'L';
370 $pdf->write1DBarcode('LEFT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
372 $pdf->Ln(2);
374 // Center alignment
375 $style['position'] = 'C';
376 $pdf->write1DBarcode('CENTER', 'C128A', '', '', '', 15, 0.4, $style, 'N');
378 $pdf->Ln(2);
380 // Right alignment
381 $style['position'] = 'R';
382 $pdf->write1DBarcode('RIGHT', 'C128A', '', '', '', 15, 0.4, $style, 'N');
384 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
385 // TEST BARCODE STYLE
387 // define barcode style
388 $style = array(
389 'position' => '',
390 'align' => '',
391 'stretch' => true,
392 'fitwidth' => false,
393 'cellfitalign' => '',
394 'border' => true,
395 'hpadding' => 'auto',
396 'vpadding' => 'auto',
397 'fgcolor' => array(0,0,128),
398 'bgcolor' => array(255,255,128),
399 'text' => true,
400 'label' => 'CUSTOM LABEL',
401 'font' => 'helvetica',
402 'fontsize' => 8,
403 'stretchtext' => 4
406 // CODE 39 EXTENDED + CHECKSUM
407 $pdf->Cell(0, 0, 'CODE 39 EXTENDED + CHECKSUM', 0, 1);
408 $pdf->SetLineStyle(array('width' => 1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(255, 0, 0)));
409 $pdf->write1DBarcode('CODE 39 E+', 'C39E+', '', '', 120, 25, 0.4, $style, 'N');
411 // ---------------------------------------------------------
413 //Close and output PDF document
414 $pdf->Output('example_027.pdf', 'I');
416 //============================================================+
417 // END OF FILE
418 //============================================================+