I want to print "Barcode"(image) in invoice means when we generate invoice from admin panel the that invoice should contain all product related details along with barcode image .I saw all questions related to above problem but i did't satisfy.

Please tell me step by step instruction where we have to modify files (file path) for adding barcode attribute to pdf.

  • This is similar to your, plez check. Commented Jun 16, 2015 at 12:47
  • i saw this but i didn't understand where (file path)this 'Mage_Sales_Model_Order_Pdf_Packaging ' i will get.How can i modify that file?
    – Urvashi
    Commented Jun 16, 2015 at 12:53
  • Is any one have solution for this??
    – Urvashi
    Commented Jun 25, 2015 at 6:07
  • 1
    Mage_Sales_Model_Order_Pdf_Packaging is in app/code/core/mage/sales/model/order/pdf/packaging. Commented Jun 25, 2015 at 6:09
  • i added that code there but it was not working.any other solution you have.....when we generate invoice from admin panel then porducts detail only display in that pdf file ..
    – Urvashi
    Commented Jun 25, 2015 at 6:50

2 Answers 2


We implemented a barcode on the PDF in FireGento_Pdf. In this case, the barcode represents the order number. But you could have a look at the code to see how it is done here. The main part is this:

$barcodeConfig = array(
    'drawText' => false,
    'orientation' => 90,
    'text' => $order->getIncrementId()
$rendererConfig = array(
    'verticalPosition' => 'middle',
    'moduleSize' => 0.9
// create dummy Zend_Pdf object, which just stores the current page, so that we can pass it in
// Zend_Barcode_Renderer_Pdf->setResource()
$pdf = new Zend_Pdf();
$pdf->pages[] = $page;
/** @var $renderer Zend_Barcode_Renderer_Pdf */
$renderer = Zend_Barcode::factory('code128', 'pdf', $barcodeConfig, $rendererConfig)->setResource($pdf, 0);
// calculate left offset so that barcode is printed on the right with a little margin
$leftOffset = $page->getWidth() - $renderer->getBarcode()->getWidth(true) * $renderer->getModuleSize() - 10;

I have created POS scanning barcode in magento invoice. It's very simple and easy to customize for single product or invoice number.

Edit : app\code\local\Mage\Sales\Model\Order\Pdf\Invoice.php

$fontPath = 'fonts/code39.TTF';                                
$barcodeImage = "*".$pro_sku."*";
$page->setFont(Zend_Pdf_Font::fontWithPath($fontPath), 36);

//Draw image to PDF
$page->drawText($barcodeImage, 400, 800);

POS easy to scan code39 fonts.

  • The core should not be edited. The class should be overridden via a custom module.
    – Andy Myers
    Commented Dec 11, 2016 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.