Edit pdf Invoice printout
Got this from the Magento Forum. Here are the downsides for this method
1. These modifications WILL be overwritten if you try to upgrade.
2. This is a pain to do– and a bit mathy.
3 files in question to customize the invoice PDF are:
/app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php
/app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php
/app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php
If ALL you want to do is change the font size, then it’s quite easy. If, however, you want to change the font (I changed it to helvetica for a smaller PDF file size since Helvetica does not have to be embedded) or change the paper size to US Letter, then you have a lot of tweaking to do.
The PDFs are creating using Zend_Pdf. So it may be useful to look through http://framework.zend.com/apidoc/core/ (Select Zend_Pdf from the dropdown in the top right corner).
Let’s start with the font and/or font size. Start with /app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php. There are 3 private methods called _setFontRegular(), _setFontBold(), and _setFontItalic() which are used through Abstract.php as well as Invoice.php. Anytime you see a call to one of these 3 methods, that is where the font is being set for a particular bit of text. The second parameter is the size (default is 7pt). So, to change the font size, find the call you want and change the second parameter. For example, the insertAddress() method could be changed to $this->_setFontBold($page, 9) if you wanted a 9pt font.










It’s really a shame this isn’t in a config.xml as it should be. Having these calls repeat the same [ridiculously small] font size is professionally inexcusable from an engineering perspective.
I can’t think of any client who wants their reports printed with a 7px font.
strange, I tried this, and the invoices all still print with 7 point fonts. Is there a cache I need to clear, or something I may be overlooking?
Yes, you should clear your cache.
System -> Cache Management
did that…I have caching turned off completely. Still no change. It doesn’t store a file cached version on the server or something like that does it? Something outside the control of the admins cache management?
I think there is another Abstract.php on
/app/code/core/Mage/Sales/Model/Order/Pdf/Items/
Try doing the same changes to this file. See if it would work.
I had already looked at that file as well and changed the one or two instances I found there. Strange. This change should work against existing orders in the system right? In other words, it doesn’t generate these documents at order time and as status’ change does it?
kr,
I have the same problem here. I have tried everything and can’t get the invoice fonts to change at all. It makes no sense. I’m wasting a lot of time trying to fix this.
Leave your response!
More About The Site
Translation:
Archives
Categories
Links
Recent Entries
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.
Recent Entries
Most Commented
Most Viewed