1

My first problem regarding the invoice is solved when I used DejaVuSans.ttf font instead of Magento default font that removes the boxes that are hiding the Rupee Signs. My new problem is, the SKU number, Price, Qty, Tax, Subtotal of the product is not coming aligned below their respective headers in invoice when i downloaded the invoice from the admin panel by clicking on Print button. All info are coming slightly moved towards to its right. I attached the screenshot for proper understanding. Still this issue is not solved.

enter image description here

5
  • it's font issue Commented Apr 29, 2017 at 4:41
  • How to fix this issue Commented Apr 29, 2017 at 4:42
  • check this and this Commented Apr 29, 2017 at 4:45
  • i had the same problem. In my case the issue was the font i was using did not supported the currency symbol. If you can share the currency and font may be i can help you Commented Apr 29, 2017 at 4:53
  • I had read your Change font suggestions blog, so do i have to make the changes in abstract.pdf on line no#793 only Commented Apr 29, 2017 at 4:57

1 Answer 1

1

Magento uses the Linux Libertine True Type Font to create the PDF.

It is defined in

app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php

in 3 instances, near lines 793,807 and 821

Unfortunately this font does not have the Indian rupee sign glyph (U+20B9) !!

That is why you get these boxes.


You can replace the font with one that does have the glyph. I'm not an expert but using a charachter map I found that arial does have the charachter (U+20B9)

In order to do that, first copy

app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php

to

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

You will be editing this new file. You have two options either upload your own font or use a built-in one.

1. Using built-in font

Replace the following three lines respectevily:

$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_Re-4.4.1.ttf');
with
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);



$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf');
with
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);



$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_It-2.8.2.ttf');
with
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_ITALIC);

2. Uploading your own font

upload your font on any dir on your derver, preferably in /lib/my_font/ then tweak the three paths mentioned above to use your files.

for example, change

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

to

$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/my_font/MyFontRegular.ttf');
10
  • 1
    Sorry for the late reply @Yiorgos Commented Mar 27, 2017 at 6:23
  • I had used your code, but after changing & clicking on Print command pdf downloads & i see nothing the boxes are gone but the prices are not visible i see all blank fields instead of boxes Commented Mar 27, 2017 at 6:25
  • This means that the font does not ender correctly. Have you tried uploading your own font? Commented Mar 27, 2017 at 8:21
  • No i had not tried Commented Mar 28, 2017 at 15:01
  • Sorry for the late reply @Yiorgos. I had tried to change the fonts by downloading & uploading. I am getting "There has been an error processing your request..." error after clicking on print button of invoice pdf Commented Apr 4, 2017 at 16:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.