How to change the background color of default magento generated invoice pdf that's generated to print?

How to change the background color of default magento generated invoice pdf that's generated to print?

October 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to change the background color of default magento generated invoice pdf that's generated to print?

Changing the Background Color of Default Magento Invoice PDF

As an experienced e-commerce developer, I often receive queries about customizing the appearance of printed invoices generated by Magento. In this post, we’ll guide you through changing the background color of the default invoice PDF that’s generated for printing in the admin panel.

Understanding Magento’s Invoice Generation Process

Before diving into the code, let’s briefly understand how Magento generates these invoices:

  • When an order is invoiced or printed from the backend, Magento calls the Mage_Adminhtml_Block_Sales_Order_Pdf_Invoices block.
  • This block uses a layout XML file (sales.xml) to define the PDF generator and template.
  • The actual content of the invoice is generated using the Mage_Sales_Model_Order_Pdf_Items_Sender class.

Locating and Accessing the Invoice Template

To modify the background color, you’ll need to locate and access the invoice template file. By default, this template is located in the following directory:

app/design/adminhtml/default/default/template/sales/order/pdf/invoice.phtml

Before making any changes, ensure you have a backup of your theme files.

Changing the Background Color

Now let’s proceed to modify the background color of the invoice. Open the invoice.phtml file in your preferred code editor and look for the <style> tag within the <head> section. You’re looking for something like this:

<style>
    /* ... */
</style>

Within this <style> block, you’ll find various CSS rules defining the style of the invoice. To change the background color, add a new rule targeting the body element, as shown below:

<style>
    /* ... existing styles... */

    body {
        background-color: #ffddcc;
    }
</style>

In this example, we’ve changed the background color to a light orange (#ffddcc). You can replace this value with any valid CSS color you prefer. The changes will apply globally to all invoices generated in that theme.

Clearing Cache and Testing

After making your changes:

  1. Save the invoice.phtml file.
  2. Clear your Magento cache by navigating to System > Cache Management and selecting “Flush Magento Cache”.
  3. Log out of the admin panel and log back in.
  4. Navigate to Sales > Orders, select an order that has been invoiced, and click the “Print Invoice” button.

You should now see the modified invoice PDF with your chosen background color. If you’re not satisfied with the result, feel free to experiment further with CSS styles within the invoice.phtml file.

Conclusion

In this post, we’ve demonstrated how to change the background color of Magento’s default invoice PDF using a straightforward approach. By understanding the generation process and locating the relevant template file, you can easily customize the appearance of invoices without extensive development work.

Remember that theme customization is an essential part of creating a unique shopping experience for your customers. If you need further assistance with Magento themes or any other development tasks, don’t hesitate to reach out to our team at Laravel Company. We’re always ready to help you build and optimize your e-commerce platform.

Happy coding!

Themes Admin Orders

Our network