Wednesday 29 May 2013

Magento-Adding custom fonts in PDF Invoice

 - In magento Invoice page pdf generation  has default fonts only, so we can use that fonts only.

 - The font families are

- Constants for the standard 14 PDF font names are defined in the Zend_Pdf_Font class:
  • Zend_Pdf_Font::FONT_COURIER
  • Zend_Pdf_Font::FONT_COURIER_BOLD
  • Zend_Pdf_Font::FONT_COURIER_ITALIC
  • Zend_Pdf_Font::FONT_COURIER_BOLD_ITALIC
  • Zend_Pdf_Font::FONT_TIMES
  • Zend_Pdf_Font::FONT_TIMES_BOLD
  • Zend_Pdf_Font::FONT_TIMES_ITALIC
  • Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC
  • Zend_Pdf_Font::FONT_HELVETICA
  • Zend_Pdf_Font::FONT_HELVETICA_BOLD
  • Zend_Pdf_Font::FONT_HELVETICA_ITALIC
  • Zend_Pdf_Font::FONT_HELVETICA_BOLD_ITALIC
  • Zend_Pdf_Font::FONT_SYMBOL
  • Zend_Pdf_Font::FONT_ZAPFDINGBATS

    - If we want to add our custom font we need to do the following steps,

    i) First we need to download the font file(.ttf) from web.
    ii) and then placed create one folder in root path and put it there - 'font/verdana.ttf'.

    $cFont = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir().'/font/verdana.ttf');

    $pdfPage->setFont($cFont36);


    - Now the font will apply to the following text in pdf.



2 comments:

  1. I have added hindi names of products on my website, it work perfect in order email, but it does not show hindi content on invoice PDF file, it shows xxxx. How do I resolve this? Which font should I add to pdf invoice? how do I do it

    ReplyDelete
  2. I have added hindi names of products on my website, it work perfect in order email, but it does not show hindi content on invoice PDF file, it shows xxxx. How do I resolve this? Which font should I add to pdf invoice? how do I do it

    ReplyDelete