One of my favourite features of the PDF file is the ability to add links so that the user can move between pages. Not only can you have clickable links on a page (which can take you to other documents or sites) but you can also have an list of bookmarks – a proper index. Here is an example of the Adobe PDF Reference Specification in our PDF viewer.
The text can be set by the user – in this case Adobe has used the Chapter and section headings of the printed version – and links nested to any depth. Clicking on the link takes you there. Not only can it specify a page, but a position on a page and you can have some other fancy tricks like altering the scaling to fit. This makes the PDF experience both more like a traditional book and also interactive.
The actual data for the Bookmarks is stored in a set of linked PDF objects and you can scan down the tree to extract all the data. If you want to play with bookmarks outside the Viewer, we have written a code example to convert them into a single XML tree.
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!
Latest posts by Mark Stephens (see all)
- 4 ways Companies can make remote working successful - December 21, 2017
- My experience of a Turkish bath (visiting Istanbul for DevFest) - November 24, 2017
- My 5 key takeaways from JavaOne 2017 - October 6, 2017
- My notes and pictures from thursday JavaOne 2017 - October 5, 2017
- My notes and pictures from Wednesday JavaOne 2017 - October 5, 2017