Develo Design


Magento 2 – add new Column to the sales Invoice PDF

Magento 2 PDF

We recently had to update Magento’s sales invoices to include an additional product attribute (Pack Size) into the PDF. Without purchasing a large extension this update can be made pretty quickly with some custom code.

As ever with a system of Magento’s complexity this does take a little setup and it’s not just editing a few files.

Step 1 – create new module

As we’re going to be doing a few updates I created an AdminOverrides module.


First we need to register the module,

Create the basic module at app/code/Develo/AdminOverrides/etc/module.xml

To override the PDF classes function in an upgrade safe way we must use the Dependancy Injection system,


Here’s the final file structure of the module.

Magento 2 module file structure

Then in your local files override just the functions that you need. In my case it was

  • The _drawHeader(\Zend_Pdf_Page $page) function of Magento\Sales\Model\Order\Pdf\Invoice
  • The draw() function of Magento\Sales\Model\Order\Pdf\Items\Invoice\DefaultInvoice

Just define your call to override the original class and override just the functions you need.


Loading Disqus Comments ...
Loading Facebook Comments ...

Post Comment

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

Discuss My Project

We want to hear about your project! Provide us with a few details and we’ll get back to you for a chat.