I want to generate a barcode and underneath a button so that the user can just click it and then print. However I haven’t been able to do this so now I have this code:
$page = new Zend_Pdf();
$imageResource = Zend_Barcode::draw('code39', 'image', $barcodeOptions, $rendererOptions);
imagejpeg($imageResource, 'barcode.jpg', 100);
$img = Zend_Pdf_Image::imageWithPath('barcode.jpg');
//echo $randomTxt;
echo '<br/>';
echo '<img src="'. base_url() .'/images/logo.png"/>';
echo '<img src="'. $img .'"/>';
However I get the following error:
A PHP Error was encountered
Severity: 4096
Message: Object of class
Zend_Pdf_Resource_Image_Jpeg could not
be converted to stringFilename:
views/vista_codigoDeBarras.phpLine Number: 19
I have no idea how to accomplish what I need and it’s sort of urgent now =/ any idea how I can do it? I’m using Zend framework to generate de barcode within CodeIgniter
I’m a bit confused on what you’re trying to achieve, but
Zend_Pdf_Imageis made for adding images to PDF documents. Given your requirement:There are a few ways you can accomplish this. First off is to create a php script that simply outputs a barcode image, and use that as the
srcattribute of the image:Source: http://framework.zend.com/manual/en/zend.barcode.creation.html
The user can then just open the image in a new tab or download and print it.
The other option is to offer them a PDF download, which is a bit more complicated than I can devote the time to providing sample code for, but this link explains how to generate PDFs using the
Zend_PDFclass:http://devzone.zend.com/article/2525