Site iconJava PDF Blog

How do Layers work in a PDF file?

One of the really cool features about PDF files is that they are not a boring, static file format – they can interact with the user and the display can change. One of my favourite interactive features is Layers.

You can think of Layers as a separate overlaid page on which text or images can be added. The Layer can have a name and the user (or the PDF itself) can alter whether this Layer is visible or not.

This has lots of practical and fun uses. There is a PDF version of the Hangman game which uses Javascript to think of a word and progressively update the display as the user plays the game.

All the parts to the Hangman drawing are on Layers and updated by Javascript.

A more practical example is to allow additional information to be included on plans, diagrams or maps

And we can see just the detail we want with a couple of clicks…

Layers are also useful as we can display different things in a printout compared with onscreen display.

So Layers offer a very powerful and user-friendly way to enhance your PDF files for useful purposes or just for fun. If you have seen any really interesting uses of Layers, why not drop me an email or post the link here.