Shopping Cart

You have no items in your shopping cart.

30 days money back

We will refund to you if you want to return a product for any reason during 30 days after purchasing it. Read More...

6-month free support included

We guarantee free and fast support during the 6-month term after purchasing a product. Read More...


If you find any bugs in our product during the support term, we will fix them for free. Read More...

Swipe to the right

Change Fonts and Reduce File Size for PDF Invoice in Magento

By Igor Goltsov June 21, 2012 11325 Views 4 comments

We and our clients often meet a situation where we need to print an Order Invoice for a particular customer.
If you ever noticed, the size of a PDF Invoice file is roughly 1.5Mb. It is not a problem if you only need to download a single file. But in a situation where we need to download 10, 20 or 50 files in one go; the total download size will increase dramatically. This becomes a headache especially when you need to get these files urgently.

We have analyzed this problem and found a solution to reduce the size of PDF Invoice files. The reason why the PDFs are so large by default is because magento is using the following font


which is attached to every file. This font file by itself is 1.5MB. We can replace these fonts with Zend_Pdf default fonts. This way we will get smaller file size for our PDFs. In order to do this, just open the file:


find lines

$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertineC_Re-2.8.0.ttf');

and replace them with

$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);

The font of Pdf files will be as readable, though not as beautiful as before. And the size of file will be reduced by minimum 5 times.

If you want to increase the text size on the PDF Invoice for billing and shipping addresses, it can be done by modifying exact same file. Simply change the lines:

protected function _setFontRegular($object, $size = 7)
protected function _setFontBold($object, $size = 7)
protected function _setFontItalic($object, $size = 7)


protected function _setFontRegular($object, $size = 9)
protected function _setFontBold($object, $size = 9)
protected function _setFontItalic($object, $size = 9)


As you can see we simply increased the default size value. In order to preserve your modifications from future Magento upgrades you need to copy:




and enter your changes there.

Enjoy your Day!

Ultiminio Ramos Galán August 14, 2012 at 3:36 AM
Thanks alot for this post, you save me a plenty hours and many headaches.
Vishva Shrivastava October 17, 2012 at 8:16 AM
Really Nice , Worked for me .Thans a lot !!!
Easy PDF Invoice October 18, 2012 at 10:45 PM
Here is what you need
You can modify the invoice PDF without knowledge about programming.
Ankit Chalany July 29, 2013 at 10:38 AM
Very helpful Article, saves a lot of time. Thanks for the pleasure!!