FAQ Item

« Return to FAQ database

Add custom font to PDF invoices

example: adding the Ubuntu font from here: http://font.ubuntu.com/

  1. Download the font file from http://font.ubuntu.com/ - unzip this to your desktop.
  2. Copy the 4 files  Ubuntu-R.ttf and Ubuntu-RI.ttf and Ubuntu-B.ttf and Ubuntu-BI.ttf to includes/plugin_pdf/html2ps/fonts/
  3. Edit the file includes/plugin_pdf/html2ps/html2ps.config 
  4. after the first <fonts> entry, add this:

    <family name="ubuntu">
    <normal normal="Ubuntu-R" italic="Ubuntu-RI" oblique="Ubuntu-RI"/>
    <bold normal="Ubuntu-B" italic="Ubuntu-BI" oblique="Ubuntu-BI"/>
    </family>

  5. down a bit furst after the first <fonts-pdf> entry, add this same code again:

    <family name="ubuntu">
    <normal normal="Ubuntu-R" italic="Ubuntu-RI" oblique="Ubuntu-RI"/>
    <bold normal="Ubuntu-B" italic="Ubuntu-BI" oblique="Ubuntu-BI"/>
    </family>

    <ttf typeface="Ubuntu-R" embed="1" file="Ubuntu-R.ttf"/>
    <ttf typeface="Ubuntu-RI" embed="1" file="Ubuntu-RI.ttf"/>
    <ttf typeface="Ubuntu-B" embed="1" file="Ubuntu-B.ttf"/>
    <ttf typeface="Ubuntu-BI" embed="1" file="Ubuntu-BI.ttf"/>

  6. Go to your invoice print template and add this code somewhere as a test:

    <p>
    <span style="color: #333333;">
    Testing Ubuntu font family<br />
    <span style="font-family: ubuntu;">Testing Ubuntu font family</span><br />
    <span style="font-family: ubuntu;"><strong>Testing Ubuntu font family</strong></span><br />
    <span style="font-family: ubuntu;"><em>Testing Ubuntu font family</em></span><br />
    <span style="font-family: ubuntu;"><strong><em>Testing Ubuntu font family</em></strong></span>
    </span>
    </p>

    The result should be this when printing a PDF