Zain Zain is a Java developer. His is a knowledge seeker who likes to try out and explore new things.

What are Appearance Streams in PDF files?

1 min read

AP Streams
At IDR Solutions this month I have spent time re-coding our AP Streams code for our PDF parser in the JPedal Java PDF Library SDK. I have learnt about Appearance Streams in more detail. There is a lot of detail involved in AP Streams so I would like to share my knowledge on AP Streams with you.

What are AP Streams?
AP Streams, or Appearance Streams are embedded PDF streams inside PDF files that enable you to display better visual and interactive content. They can consist of anything that can visually be displayed, whether they are checkboxes, logos, fancy text, radio buttons, etc. This means that their sizes can be as small as needed and can have multiple AP Streams within a PDF file. The visual display of the stream can change instantly when clicked which makes PDF files interactive.

Why AP Streams?
So why do we need AP Streams? You can just show the text value for a Form Object but often you want something more flexible and slick. We can easily create our own images and code the PDF to show far more than just plain text. This means we can choose to have a big red ‘X’ instead of an empty checkbox or a bigger blue exclamation mark in the text.

How do AP Streams work?
An AP Stream consists of 3 keys: Normal (N), Down (D), and a Rollover (R) key. The N value is the normal appearance of the object; the R value is the appearance of the object when the mouse is hovered over it; the D value is the appearance when the object is being pressed on by the mouse. While the N key must have a value, the R and D keys are optional.

An AP Stream also has 2 states. Although these 2 states can be anything, they are generally named ‘On’ and ‘Off’. AP Streams alternate between these 2 states, displaying different images for each state. For example, the ‘Yes’ state in the below example might display a checkbox with a tick while the ‘Off’ state would display a checkbox without a tick.

firefox_2016-10-17_15-48-10

In conclusion, AP streams are one of those PDF features which allows us to build high quality documents for our users to display. Are you using them?



Our software libraries allow you to

Convert PDF files to HTML
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
Read and write HEIC and other Image formats in Java
Zain Zain is a Java developer. His is a knowledge seeker who likes to try out and explore new things.