Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Be careful with your PDF fonts

1 min read

You need to be careful with fonts in PDF files. I was sent a PDF file which did not display properly in our software. So I opened it in Acrobat on my Mac, and guess what… It did not display properly in that either. It did however work correctly in Acrobat on Windows. The problem turned out to be in the fonts.

Many PDF creation tools let you add fonts into a PDF file if they are on your system. But they do not include critical font data (like the widths of the characters so the font can be approximated or the actual font data). So when you try to open the file on a different machine (without this font), it does not look correct.

In theory, the PDF file format provides a set of standard font families you can use. However,  one of the fonts not correctly displayed on my problem PDF was Symbol – the Mac version of Acrobat seemed confused because it was WIN encoded.

The best solution is to embed the font which includes all the information needed to draw it and makes no assumption about what is on the viewing machines. If you subset the font, only the minimum data to draw the required glyphs is included, making it compact.

So be careful with your fonts, and if you are not embedding them, make sure you test the PDF files on any viewing platforms.

This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!

Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

2 Replies to “Be careful with your PDF fonts”

  1. Hie, I used some library to convert pdf to tiff, in java 1.7. It perfectly fine on windows but in linux it didn’t show the correct font. Can you please guide me what else I have to write or which jar I have to use to maintain the fonts.

    Thanks in advance 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *