Magento PDF invoice with product images extension

Magento PDF invoice with product images extension

Hello everyone, short while after I wrote article Add custom attribute to Magento’s PDF invoice I received quite a number of requests for explanation on how to add products images to PDF invoice. As I had some time, I’ve created an extension that will do just that.

So, this extension is based on old one with custom attribute. It’s tested on Magento Professional 1.9, and will show thumbnails of product images (if those images exist, and Magento can read them) together with products on invoice.

Here’s a screenshot of one of my last tests:

After you’ve seen it and that’s what you require, you can download it here.

Installation process comes down to extraction of files / directories over your “app” directory.


Notes:
It won’t work with “custom attribute” extension I wrote earlier.
As always, please make backup before installation, as this is provided for usage at your own risk.

Cheers!

You made it all the way down here so you must have enjoyed this post! You may also like:

Magento 2 Product Quick View Tomas Novoselic
, | 6

Magento 2 Product Quick View

Optimize Elasticsearch autocomplete URL for Google Analytics Matej Djakovic
Matej Djakovic, | 2

Optimize Elasticsearch autocomplete URL for Google Analytics

Inchoo’s compatibility extension for Magento 1 and PHP 7 Ivan Curdinjakovic
Ivan Curdinjakovic, | 71

Inchoo’s compatibility extension for Magento 1 and PHP 7

24 comments

  1. Hi, i have a magento 1.9.2. I just downloaded the code and installed it to my site. But it looks nothing different—i mean the pdf invoice does not show any images. So my questions are: do i need to install the Custom Attibute extension before i install this PDF invoice with images? and another question is, does this fit magento 1.9.2? Thanks! Larry

  2. This extension was working perfectly for me till i implemented CDN. Now the invoice is getting generated but without the product images.

    I am not sure what variables to edit to ensure we get back the images to load?

    Can you help?

    Balu

    For BSYNC Fashion

     

  3. We are obsessed with your extension that displays the product images for
    invoices. This will help us communicate better with our suppliers and
    customers. However we noticed that when the name is lengthy, it overlaps
    the SKU field and the images are shifted below.

    Can this be fixed?

    see screenshot

    1. /app/code/local/Inchoo/Invoice/Model/Order/Pdf/Invoice.php
      around #85 change this this line
      $page->drawText(Mage::helper(‘sales’)->__(‘SKU’), 280, $this->y, ‘UTF-8’);
      also page #145
      $page->drawText(Mage::helper(‘sales’)->__(‘SKU’), 280, $this->y, ‘UTF-8’);

      app/code/local/Inchoo/Invoice/Model/Order/Pdf/Items/Invoice/Default.php
      change this

      // draw SKU
      $lines[0][] = array(
      ‘text’ => Mage::helper(‘core/string’)->str_split($this->getSku($item), 25),
      ‘feed’ => 280
      );

  4. mohan if you will replace :
    $imageLocation = substr($imagePath,strlen(Mage::getBaseUrl()));
    BY :
    $imageLocation = substr($imagePath,strlen(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)));

    IN app/code/local/Inchoo/Invoice/Model/Order/Pdf/Invoice.php
    Line: 27
    As written by Max above, It will work perfectly.

  5. Hi,
    i changed the app with the downloaded and work on it but i didnt get product image on my invoice pdf

  6. Hi , thanks for this solution , but on magento 1.7 the product image isnt visible on PDF . What can i do to correct this situation ?

  7. hey i came here thrice, but the plugin/extension is not working. any good guide to make it work on latest magento version that is 1.7.x

  8. This will reduce the line spacing on the invoice so that it makes a little more sense and allows for more products to fit on a single invoice page.

  9. Christopher,

    In app/code/local/Inchoo/Invoice/Model/Order/Pdf/Items/Invoice

    Open Default.php , scroll to the bottom and find:

    //Edited default line height
            $lineBlock = array(
                'lines'  => $lines,
                'height' => 60

    TO:

    //Edited default line height
            $lineBlock = array(
                'lines'  => $lines,
                'height' => 20
  10. Does this/Should this work with magneto 1.7?
    My client is migrating from etsy, and I’d like to provide as familiar a workflow as I can.

  11. @tutela would you specify what do you mean?

    If I got your point, the image is the image associated for some of the ordered / invoiced products. You can control this from Magento admin panel -> edit product -> tab Images.

    Physically the images usually are placed in /media/catalog/* or /media/tmp/*

  12. Try to replace
    $imageLocation = substr($imagePath,strlen(Mage::getBaseUrl()));

    $imageLocation = substr($imagePath,strlen(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)));

    1. Hello. This solve my issue. Now image is printed on invoice.
      Question: Can be extended also to shipments, not only for invoice?
      Thanks

  13. Dear Mladen, I have the same issue as Meral, I can see the new column with “Product Image” but I dont see the pictures.

    Thank you very much for your great job!!

    Best regards,

    Alejandro

  14. Hi you code is not work for me. It creates a column of ‘Product Image’. But under that no images are showing. Right now i am working with my local machine.

    Thanks for further help.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.