I had to debug an intriguing mystery to investigate this morning (while listening to Hercule Poirot naturally enough). It shows off some interesting features of the PDF file format and Acrobat, so let’s recreate the crime and give you the solution… (you will need to provide your own soundtrack).
The problem was that our PDF viewer was not displaying the Euro symbol correctly (while it appeared correctly in Acrobat). So the first step was to find out some more about the PDF. I used our PDF viewer to find out what the PDF was created with and more details about the fonts (you can get the same information in most PDF viewers). The PDF file was created with PDF lib and contains embedded Truetype fonts.
So the next stop is to open the PDF file in Acrobat and see how the fonts are setup. The value in the PDF file for the character is the Standard Euro value (decimal 128). The index value is usually mapped onto a glyph value in the CMAP table. Acrobat has a nifty feature to show us these tables.
There are 2 tables mapping glyphs onto the actual glyph values in the PDF font data. In theory they should give identical results. The solution is actually in the second table. The CMAP lists the glyphs (usually by name) and the connected glyph number in the file. It also shows a preview of the glyph.
Here is our answer. Glyph 57 is the Euro symbol but it is identified not by the glyph name but by 20ac – the unicode value for Euro. Hm… not sure I could find that in the PDF specification, but Acrobat accepts it and adding it in fixes the display in our PDF viewer.
There are several lessons to be learnt from this little mystery. Having the right tools is essential to track down issues, and expect to find some slightly odd things going on inside some PDF files. Oh, and have something appropriate to listen to in the background…
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!
This post is part of our “Fonts Articles Index” in these articles we explore Fonts.
Latest posts by Mark Stephens (see all)
- My experience of a Turkish bath (visiting Istanbul for DevFest) - November 24, 2017
- My 5 key takeaways from JavaOne 2017 - October 6, 2017
- My notes and pictures from thursday JavaOne 2017 - October 5, 2017
- My notes and pictures from Wednesday JavaOne 2017 - October 5, 2017
- My notes and pictures from Tuesday JavaOne 2017 - October 4, 2017