I want to customize layout of PDF invoice by css and by adding product image on invoice in magento 2.


For customization or changing layout of pdf invoice we use zend framework's library functions and we need to override some files like:

  1. Magento\Sales\Model\Order\Pdf\Invoice
  2. Magento\Sales\Model\Order\Pdf\AbstratcPdf
  3. Magento\Sales\Model\Order\Pdf\Items\Invoice\DefaultInvoice
  4. etc.

In this files we can add custom variables, Change layout or add custom footer or table for Invoice PDF.

| improve this answer | |

As far as I know, CSS is only used for styling HTML and XHTML. So, in your case, we should use some PDF libraries for generating PDF files from HTML:


| improve this answer | |

I hope this can help you. Here is enough explanation to fulfil your needs.

Magento 2: How to add footer in pdf invoice?

| improve this answer | |

You can try "PDF CUSTOMIZER" M2 extension from PotatoCommerce. This extension converts HTML and CSS to PDF documents automatically. In fact, it replaces native Magento templates with custom templates, which can be edited just as normal HTML page. PDF Customizer uses wkhtmltopdf library. For example, product image can be added to PDF this way:

 <img src="{{var item|small_image}}" width="100" height="100"> 

You can see all available variables on this page: PDF Customizer

| improve this answer | |
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Keyur Shah Mar 19 '18 at 19:13
  • I've edited my content. Is that good now? – Stas Leo Mar 20 '18 at 20:47

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.