One of the really useful features of the PDF file format is the ability to have interactive elements. These began as just simple checkboxes, buttons, comboboxes and textfields type widgets and the list has expanded to include the ability to embed Sounds, Movies and even other files or URLs. This makes the PDF file format a very interactive medium.
Here is one of my favorite examples:
All of these interactive features can be defined in 2 ways. Firstly, they can exist in as PDF objects defined within the PDF file and they inherit values from their parent objects. This is the original FDF version. It uses the standard PDF Cos format and would look something like this
26 0 obj
/Rect[196 594 314 613]
/P 24 0 R
/AP<</N 142 0 R>>
/MK<</BC[0 0 0]>>
/Opt[(Burrito)(Soft Taco)(Mexico City)(Quesadilla)(Taquitaco)]
/DA(/TiRo 0 Tf 0 0 1 rg)
Or they can appear in one of several XML structures inside the file. Here is an example – the actual XML is buried inside streams in the referenced objects.
/XFA[(preamble)40 0 R
(config)41 0 R
(template)42 0 R
You can also define as both a Cos object with data in the XFA – the spec is nothing if not flexible!
(datasets)43 0 R
(localeSet)44 0 R
(postamble)45 0 R]
The thing that I found most confusing when starting was that interactive elements can actually be referenced in 2 separate ways. A PDF document can have a single Acroform or XFA object (which lists all the widgets in the document), but each page can also have a Annots object which lists the widgets on that page. So you need to potentially look at both lists and then workout which are used on any page.
So if you think PDF files are about just static WYSIWYG documents, you have been missing a whole dimension. Give them a try.
This post is part of our “Understanding the PDF File Format” series. In each article, we aim to take a specific PDF feature and explain it in simple terms. 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!
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.
Find out more about our software for Developers
|Convert PDF to HTML5 or SVG|
|Convert AcroForms and XFA to HTML5|
|Java PDF SDK for working with PDF files|