Page tree
Skip to end of metadata
Go to start of metadata

I need to modify an invoice so I thought I would document my progress. This based on the invoice in Magento 1.1.2. If you find errors please feel free to correct them. :)

You should never edit Magento core files. So to edit this functionality the easiest way is to do the following:

Copy the contents of /app/code/core/Mage/Bundle/Model/Sales/Order/Pdf/Items/ into/app/code/local/Mage/Sales/Model/Order/Pdf/ - this file will override the original, and will not be overwritten during upgrade. The drawback is that you’ll have to make sure to apply upgrade changes of the original file to this one, to avoid incompatibility with upgraded code.

The PDF is generated using the Zend_Pdf component of the Zend Framework. Here is a little tutorial

Page format: The default invoice PDF is set up in the A4 format. To set it for letter

in /app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php


$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);


$page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);

Move Logo: When I changed the page format to Letter it moved the logo off the top. In ZEND_PDF the measurements are in Points(1/72 of an inch) and the origin is is lower left. I moved it down 50pt by subtracting 50 from the Y coordinates.

in /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php find the function insertLogo and change

$page->drawImage($image, 25, 800, 125, 825);


$page->drawImage($image, 25, 750, 125, 775);

At this point the logo under a grey box. :)

You now need to take 50px away from the rest of the elements Y coords to move everything else down. It get’s a little messy, just keep generating PDFs to watch your progress.

most of the coords are in /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php and in /app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php

Increase the lower Margin: We need some room at the bottom each page for some preprinted material that will be on each invoice.

in /app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php


if ($this->y<15) {


if ($this->y<215) {

This adds 200 points (about 2.75”) to the margin

Fonts: The the invoice uses Libertine. It’s a great font but with it the file size was 1.4MB without 8KB.

in /app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php

I changed all the references to Libertine to Helvetica with cut and paste.

In /app/code/local/Mage/Sales/Model/Order/Pdf/Items/Abstract.php I changed

 Expand source


 Expand source

Also in /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php change

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


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

Change the font size for the billing and shipping addresses in Magento

In /app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php

Edit Line 249:

Use Default Font Size


Use Custom Font Size

// The second param sets the font size
$this_setFontRegular($page, 12);

Available module




  • No labels