Perfect, thanks Mickael.
That's what I needed.

Regards
Ricardo


On Feb 12, 2010, at 7:54 PM, mikaelkael [via Zend Framework Community] wrote:

> I just tested this code without any problems (the file is located in 
> Zend test directory): 
> 
> ini_set('include_path', '../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(dirname(__FILE__) . 
> '\Zend\Barcode\Object\_fonts\Vera.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'); 
> 
> Mickael 
> 
> Le 12/02/2010 20:43, Ricardo Simão a écrit :
> 
> > 
> > But I'm loading the Pdf with Zend_Pdf. How can I chain the barcode? 
> > That's what I'm trying to do, but haven't figured it out yet. 
> > 
> > Sent from my iPhone 
> > 
> > On 2010/02/12, at 19:25, mikaelkael <[hidden email]> wrote: 
> > 
> >> Of course, if your PDF isn't loaded (or loadable) with Zend_Pdf, this 
> >> solution doesn't work ;) 
> >> 
> >> If loadable with Zend_Pdf, you can chain the barcode generation and 
> >> render your Pdf without problem. 
> >> 
> >> Mickael 
> >> 
> >> Le 12/02/2010 20:04, Ricardo Simão a écrit : 
> >>> 
> >>> Hi Mickael 
> >>> 
> >>> That also doesn't work for what I need. 
> >>> I'm loading a base Pdf with some content already. I need to inject 
> >>> several barcodes into that file. 
> >>> The values are passed via a Post form. 
> >>> Then the Pdf is rendered to the browser for printing. 
> >>> 
> >>> But thanks for your reply. If you have another solution please let 
> >>> me know. 
> >>> Thanks 
> >>> Ricardo 
> >>> Sent from my iPhone 
> >>> 
> >>> On 2010/02/12, at 13:35, mkk <[hidden email]> wrote: 
> >>> 
> >>>> Hello, 
> >>>> 
> >>>> You don't need to create a temporary image. The Pdf renderer exists: 
> >>>> $pdf = new Zend_Pdf(); 
> >>>> ... // your work 
> >>>> 
> >>>> //a font is mandatory for Pdf 
> >>>> 
> >>>> //statically 
> >>>> Zend_Barcode_Object::setBarcodeFont('my_font.ttf'); 
> >>>> //or with your options 
> >>>> $barcodeOptions = array('text' => 'ZEND-FRAMEWORK', 'font' 
> >>>> =>'my_font.ttf'); 
> >>>> $rendererOptions = array(); 
> >>>> 
> >>>> $pdfWithBarcode = Zend_Barcode::factory('code39', 'pdf', 
> >>>> $barcodeOptions, $rendererOptions)->setResource($pdf)->draw(); 
> >>>> 
> >>>> Mickael 
> >>>> 
> >>>> > Message du 12/02/10 13:31 
> >>>> > De : "rpsimao" 
> >>>> > A : [hidden email] 
> >>>> > Copie à : 
> >>>> > Objet : [fw-general] Re: How can we pass a Zend_Barcode image to 
> >>>> a Zend_PDF? 
> >>>> > 
> >>>> > 
> >>>> > 
> >>>> > Found the solution. 
> >>>> > 
> >>>> > Must create a image and pass to the 
> >>>> Zend_Pdf_Image::imageWithPath() method. 
> >>>> > so : 
> >>>> > // Only the text to draw is required 
> >>>> > $barcodeOptions = array('text' => 'ZEND-FRAMEWORK'); 
> >>>> > 
> >>>> > // No required options 
> >>>> > $rendererOptions = array(); 
> >>>> > 
> >>>> > // Draw the barcode in a new image, 
> >>>> > $imageResource = Zend_Barcode::draw( 
> >>>> > 'code39', 'image', $barcodeOptions, $rendererOptions 
> >>>> > ); 
> >>>> > 
> >>>> > imagejpeg($imageResource, 'barcode.jpg', 100); 
> >>>> > 
> >>>> > // Free up memory 
> >>>> > imagedestroy($imageResource); 
> >>>> > 
> >>>> > $image = Zend_Pdf_Image::imageWithPath('barcode.jpg'); 
> >>>> > 
> >>>> > ... 
> >>>> > $page->drawImage($image, $x1, $y1, $x2, $y2); 
> >>>> > ...
> 
> 
> 
> 
> 
> View message @ 
> http://n4.nabble.com/How-can-we-pass-a-Zend-Barcode-image-to-a-Zend-PDF-tp1478435p1489600.html
>  
> To unsubscribe from Re: How can we pass a Zend_Barcode image to a Zend_PDF?, 
> click here.
> 


-- 
View this message in context: 
http://n4.nabble.com/How-can-we-pass-a-Zend-Barcode-image-to-a-Zend-PDF-tp1478435p1490426.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to