Categories: How To

How to Override Invoice PDF in Magento

Well designed and properly formatted invoices always make a good impression and sometimes badly required to fit enough and needful business information within. Defaut Magento neither provides adding more information nor allow customization as it’s way complicated. While working with one of our extensions, we need to change the layout & override default Invoice PDF in Magento to properly fit all the business information. You may require this custom code in your extension to fulfill custom requirements and thus I’m sharing my code here.

Put following code in Module config.xml file:

 
 
  NameSpace_ModuleName_Model
 
 
  
      NameSpace_ModuleName_Model_Order_Pdf_Invoice
   NameSpace_ModuleName_Model_Order_Pdf_Items_Invoice_Default
  
 

Now put following code in NameSpace/ModuleName/Model/Order/Pdf/Items/Invoice/ as Default.php


Simply change the code according to your requirements and test again.
I hope this code has helped you!
Cheers!
Click to rate this post!
[Total: 4 Average: 3.3]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate ?️ Certified Magento Developer?‍?. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.?

View Comments

  • Mage::helper('core/string')->str_split($loremIpsum, 60, true, true);
    when i use this i get an error that '...\...\...\Mage' is not found in my defaultInvoice.php file can you please guide.

  • Mage::helper('core/string')->str_split($loremipsum, 60, true, true) when i do this i get an error that the '...\...\...\Mage' not found in my defaultInvoice.php file i suppose that Mage::helper should be available please guide i am stuck! thanks.

Recent Posts

How to Integrate and Use MongoDB with Laravel?

MongoDB is a popular NoSQL database that offers flexibility and scalability when handling modern web…

1 day ago

NodeJS | Callback Function

In NodeJS, callbacks empower developers to execute asynchronous operations like reading files, handling requests, and…

2 days ago

How to Show SKU in Order Summary in Magento 2?

Hello Magento Friends, In today’s blog, we will learn How to Show SKU in Order…

4 days ago

Best Colors to Use for CTA Buttons

The "Buy Now" and "Add to Cart" buttons serve as the primary call-to-action (CTA) elements…

6 days ago

Magento 2: How to Save Custom Field Value to quote_address for Multi-Shipping Orders

Hello Magento Friends, In Magento 2, the checkout process allows customers to choose multiple shipping…

7 days ago

Best Beginners Guide to Shopify Balance Account

If you are a Shopify admin, using a Shopify Balance Account for your business revenue…

7 days ago