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!