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

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

8 hours ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

3 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

6 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

6 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

6 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

1 week ago