Welcome to PotatoCommerce - Top Quality Magento Extensions Store

Home > Blog > How to add product image to PDF invoice

How to add product image to Magento 2 Invoice PDF

Posted on 19 July 2018

Using images in PDF invoices (as well as in other PDF documents) makes it more attractive and convenient. This becomes especially relevant when there are many products in the order, and product images make it easier to recognize products in the invoice.

Unfortunately, Magento 2 PDF documents do not display product images in PDF by default. For this reason, we have developed PDF Customizer extension, which makes it easy to customize PDF invoice templates for both customers and store administrators. With our PDF invoice module for Magento 2, you can easily customize PDF documents and add product images, as our Magento 2 PDF extension supports HTML and CSS.

Let's learn how to add product images to Invoice PDF in Magento 2

To add a product image to a PDF invoice template, you need to do the following:

  1. Create a new PDF template (or edit the existing) at Content > PDF Customizer > Templates
  2. Add this code wherever you need inside the foreach directive:
    <img src="{{var item|small_image}}" width="100" height="100">
    Surely, you can specify any width and height, as well as apply any style (margin, border, shadow, gradient, etc.) to the image, if necessary.
  3. Save the template
  4. Select your template in the extension settings (Content > PDF Customizer > Settings) and save the settings
Magento 2 custom PDF invoice

PDF template



Pretty easy, right? For your convenience, we added the needed code to the default PDF templates, so you don’t need to do anything to add product images to PDF invoice. Or you can use our code as a reference if you create new PDF template from the scratch.

PDF Customizer by PotatoCommerce is an awesome extension with a great set of features, and it’s easy to work with. Moreover, it comes with the best support policy and service conditions on the market. You can learn how our PDF Customizer wins the competition on this page.

About the Author

Author Stanislav Golodov
Stanislav Golodov, Product Management & Marketing in PotatoCommerce

Stanislav has written most of PotatoCommerce blog posts. He belives that blog posts should be really helpful and be written primarily for people, not for Googlebot. Stanislav started working with Magento in 2011 as QA, and later as Product Manager. He joined PotatoCommerce in 2017, where he is responsible for marketing, web analytics, product specifications and finalizing the scope of our products and major extension updates.