Magento: How to Print backend invoices like frontend as HTML?

Magento: How to Print backend invoices like frontend as HTML?

October 10, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: How to Print backend invoices like frontend as HTML?

Printing Backend Invoices as HTML in Magento 1

If you’re running Magento 1.7.0.2 or later, you may find that printing invoices from the backend produces PDF files rather than HTML like the frontend does. While the core functionality favors PDF generation for administrative purposes, it is possible to customize this behavior.

Understanding the Current Setup

By default, when you print an invoice via the Magento admin panel (Sales > Invoices), Magento uses Zend_Pdf and FPDF libraries to generate a PDF version of the page. This is done because PDF files are more reliable for printing complex documents across different browsers and systems.

However, in some cases, especially when you want to quickly preview or distribute invoices without actually printing them, having an HTML format can be more convenient.

Changing the Print Behavior

To achieve this, we’ll need to override the core Mage_Adminhtml_Sales_Order_Pdf_Invoice controller and modify its action. Here’s a step-by-step guide:

  1. Create a new module: In your Magento installation’s app/code/local directory, create a new folder named “YourCompany_Name”. Inside this folder, create two more folders: “Model” and “controllers”.

  2. Override the core class: Open Mage_Adminhtml_Sales_Order_Pdf_Invoice controller located at app/code/core/Mage/Adminhtml/controllers/Sales/Order/Pdf/Invoice.php. Copy its content to your local folder under YourCompany_Name/controllers/Sales/Order/Pdf/InvoiceController.php.

  3. Modify the print action: In the overridden printAction(), you need to replace the PDF generation logic with HTML rendering.

public function printAction()
{
    $orderId  = $this->getRequest()->getParam('order_id');
    $order = Mage::getModel('sales/order')->load($orderId);
    $pdf = new Zend_Pdf();

    // OLD PDF GENERATION CODE
    // ...

    // NEW HTML GENERATION CODE
    $html = '<h1>Invoice for Order #'.$order->getIncrementId().'</h1>';
    $html .= '<p>This is a sample invoice.</p>';

    header('Content-Type: text/html');
    echo $html;

    exit;
}
  1. Configure your module: Create an etc/config.xml file under app/code/local/YourCompany_Name/etc/ with the following content:
<?xml version="1.0"?>
<config>
  <modules>
    <YourCompany_Name_Magento1702>
      <active>true</active>
      <codepool>local</codepool>
      <depends>
        <Mage_Adminhtml/>
      </depends>
    </YourCompany_Name_Magento1702>
  </modules>
</config>
  1. Clear the cache: After saving these changes, clear your Magento cache from the admin panel (System > Cache Management) to ensure the new controller is loaded.

Conclusion

By following this guide, you should now be able to print invoices from the Magento backend as HTML instead of PDF. While this doesn’t change the core printing functionality, it provides a quick workaround for previewing or distributing invoices without actually needing to print them.

Remember, customizing the core in this way is generally not recommended for production environments unless you have a specific need and understand the potential risks. Consider this a development-time trick rather than a long-term solution.

For more advanced customizations in Magento 1.x and insights into Magento 2 migrations, I recommend checking out our Magento Development Services at Laravel Company. Our team is always ready to assist with complex projects that require deep Magento expertise.

Happy coding!

Magento 1 Extensions Admin Orders

Our network