Showing posts with label Adding custom fonts at invoice pdf in magento. Show all posts
Showing posts with label Adding custom fonts at invoice pdf in magento. Show all posts

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.