<?php
/*======================================================================
 PDFBarcode - Usage example
 http://www.grana.to/pdfbarcode

 Copyright (C) 2004 Valerio Granato (valerio at grana.to)
 Last Modified: 2004-06-01 21:36 CEST

 Author:  Valerio Granato (valerio at grana.to)
 Version: 0.91
 Package: PDFBarcode

 Thanks to:
 Tibor Thurnay <tibor.thurnay at swr3.de>
 - genbarcode added to programs needed to run the example



 A simple usage example - to use this example you NEED:
 - GNU-Barcode
 - Cpdf (see links above)
 - genbarcode by by Folke Ashberg (http://www.ashberg.de/php-barcode/download/)

*/

include ('class.ezpdf.php');
include (
'pdfbarcode.php');
$pdf =& new Cezpdf('a6''landscape');

$fp=popen('/usr/bin/genbarcode 1234567890'"r");
$bars=rtrim(fgets($fp1024));
$text=rtrim(fgets($fp1024));
$encoding=rtrim(fgets($fp1024));
pclose($fp);

if (
ereg('^(EAN|ISBN)'$encoding)) { $fontscale 4; } else { $fontscale 0; }

$id barcode($pdf$text$bars'1'$fontscale'20''230''./fonts/Helvetica.afm');

// the x is 28 and not 20 to align vertically to the bars
// and not to the first char
$pdf->addText(2824012$encoding); 
$pdf->addObject($id);

$fp=popen('/usr/bin/genbarcode 87217254'"r");
$bars=rtrim(fgets($fp1024));
$text=rtrim(fgets($fp1024));
$encoding=rtrim(fgets($fp1024));
pclose($fp);

if (
ereg('^(EAN|ISBN)'$encoding)) { $fontscale 4; } else { $fontscale 0; }

$id barcode($pdf$text$bars'1'$fontscale'170''230''./fonts/Helvetica.afm');

$pdf->addText(17024012$encoding);
$pdf->addObject($id);

$fp=popen('/usr/bin/genbarcode 001200130014 128C'"r");
$bars=rtrim(fgets($fp1024));
$text=rtrim(fgets($fp1024));
$encoding=rtrim(fgets($fp1024));
pclose($fp);

if (
ereg('^(EAN|ISBN)'$encoding)) { $fontscale 4; } else { $fontscale 0; }

$id barcode($pdf$text$bars'1'$fontscale'280''230''./fonts/Helvetica.afm');

$pdf->addText(28024012$encoding);
$pdf->addObject($id);
$pdf->ezStream();
?>