blog site of branko ajzele, senior developer / project manager

Invoice printing to PDF taking to long in Magento?

Recently I was assigned a task to check the slowness of PDF printing on invoice page of Magento admin. It took him around 5minutes to print PDF (return PDF document on Invoice page). After diving into the code trying to trace the issue I found what was the cause of slow printing. PDF document that gets created has the ability to include the logo in header.

Code that adds the image into the header is located under the method named “getPdf()” in “app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php” file. There is a line that says “$this->insertLogo($page, $invoice->getStore());”.

Method “insertLogo()” is located under “app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php”. When commented out the invoice gets printed to PDF in a matter of 2-3 seconds. However, simply commenting out the method is not the proper solution. After short introspection, conclusion was that the image assigned as logo was to big in dimensions (around 3500x… px). Reducing logo in size drastically improved generation of PDF.

Hope this helps someone with the same “slow invoice printing” issue.

  • pauljgregory
    Another change you can make to reduce the size of the PDF, and thus the time spent generating/downloading it, is to swap the stupid embedded Libertine font for one that's always available to PDF readers. See the Fonts section of
    http://www.magentocommerce.com/wiki/how-to/edit...
blog comments powered by Disqus
Powered by Wordpress | Designed by Elegant Themes