ZEND_PDF and Barcode on IBM i

The place for general PHP questions and hints for PHP on IBM i

ZEND_PDF and Barcode on IBM i

Postby bvirzi on Thu Aug 16, 2012 3:21 pm

Hi,

I have a problem: when I run this script on IBM i

Code: Select all
require_once 'Zend/Pdf.php';
require_once 'Zend/Config.php';
require_once 'Zend/Barcode.php';
require_once 'Zend/Mail.php';
require_once 'Zend/Barcode/Renderer/Pdf.php';
require_once 'Zend/Loader/Autoloader.php';
ini_set('include_path', '/usr/local/zendsvr/share/ZendFramework/library/');
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);

$pdf = new Zend_Pdf();
//... your work
//a font is mandatory for Pdf
Zend_Barcode::setBarcodeFont('arial.ttf');

$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-1');
$rendererOptions = array('topOffset' => 50);
$pdfWithBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdf)->draw();

$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-2');
$rendererOptions = array('topOffset' => 100);
$pdfWithBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdfWithBarcode)->draw();

$barcodeOptions = array('text' => 'ZEND-FRAMEWORK-3');
$rendererOptions = array('topOffset' => 150);
$pdfWithBarcode = Zend_Barcode::factory('code39', 'pdf',
$barcodeOptions, $rendererOptions)->setResource($pdfWithBarcode)->draw();

// and the end render your Zend_Pdf
$pdfWithBarcode->save('testbarcode.pdf');


I receive this error when I set barcode font:

Fatal error: Uncaught exception 'Zend_Pdf_Exception' with message 'Null character is not allowed in PDF Names' in /usr/local/zendsvr/share/ZendFramework/library/Zend/Pdf/Element/Name.php:56 Stack trace: #0 /usr/local/zendsvr/share/ZendFramework/library/Zend/Pdf/Resource/Font/CidFont.php(121): Zend_Pdf_Element_Name->__construct('?A?r?i?a?l?M?T') #1 /usr/local/zendsvr/share/ZendFramework/library/Zend/Pdf/Resource/Font/CidFont/TrueType.php(64):........

I think the problem is the ttf file that I upload From windows to IBM i. You can see in the figure that the name of the font is created with null characters within the framework classes.
I think that the font name is read from the file ttf. For this reason I think the ttf file is not good for IBM i.

Can you help me?

Thanks
Benny
Attachments
barcodeerrore.jpg
barcodeerrore.jpg (265.2 KiB) Viewed 974 times
bvirzi
 
Posts: 17
Joined: Tue Nov 16, 2010 3:51 pm

Re: ZEND_PDF and Barcode on IBM i

Postby jordiwes on Wed Oct 10, 2012 11:04 pm

This may or may not help, but I successfully used TCPDF on the i to generate barcodes... http://www.tcpdf.org
jordiwes
 
Posts: 14
Joined: Tue Apr 24, 2012 6:56 pm


Return to PHP Questions / Hints

Who is online

Users browsing this forum: No registered users and 1 guest