Update: JPDF2HTM5 has been rebranded as BuildVu and JPDFForms has been rebranded as FormVu

Understanding the PDF File format – bookmarks and links

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!

Related Posts:

The following two tabs change content below.

Mark Stephens

System Architect and Lead Developer at IDRSolutions
Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.
Markee174

About Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

2 thoughts on “Understanding the PDF File format – bookmarks and links

  1. Vincent Hu

    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 *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>