PDF files have a very useful feature known as XForms, which are sub-procedures. This makes it very easy to reuse code and produce smaller files. XForms can be thought of as fragments of PDF pages in their own right, with their own images and fonts and other resources, which can then be drawn onto the main page. In general they also inherit data from the main page. So if the XForm makes a call to Font TT1, it sees if it is defined in the XForm and looks in its parent if not.
However, here is an interesting XForm. It loads ant XForm called xi0. And guess what xio does? It loads a form called xio… There is no local definition of xi0 – so we default back to the main definition of xio (and round we go).
Adobe reports an error in this file and it is reasonably easy to add a check to stop this, but it is very annoying…
The PDF file format is a very powerful format but with power comes responsibility.
This article is part of a series on the more ‘unusual’ PDF files we come across while developing our PDF library. Click here for the full list.
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.