Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Understanding the PDF File format – bookmarks and links

57 sec read

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.

click on image for high resolution version
click on image for high resolution version

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!

IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

2 Replies to “Understanding the PDF File format – bookmarks and links”

  1. Good article, but could I ask some question about pdf bookmark? because we are struggling about what kinda format will be used to archiving, and also retrieve when user needs, but we will archive entire big pdf, but we would like to use bookmark to be “rang of pages”, but I checked spec of pdf, it seems like bookmark is only indicate to specific page, not a range, is it true?

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2019. All rights reserved.