Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Hercule Poirot solves the mystery of the PDF file and the missing Euro Character

1 min read

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.
PDF properties

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…



Are you a Developer working with PDF files?

Our developers guide contains a large number of technical posts to help you understand the PDF file Format.

Do you need to solve any of these problems?

Display PDF documents in a Web app
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Leave a Reply

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

IDRsolutions Ltd 2022. All rights reserved.