1

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. – Adarsh Khatri Jun 16 '15 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 Jun 16 '15 at 12:53
  • Is any one have solution for this?? – Urvashi Jun 25 '15 at 6:07
  • 1
    Mage_Sales_Model_Order_Pdf_Packaging is in app/code/core/mage/sales/model/order/pdf/packaging. – Adarsh Khatri Jun 25 '15 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 Jun 25 '15 at 6:50
1

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;
$renderer->setLeftOffset($leftOffset);
$renderer->draw();
0

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 Dec 11 '16 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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