PDF Labs

How to Export and Import PDF Bookmarks

Export and import PDF bookmark data using PDFtk Server. This bookmark data can be easily parsed or generated.

You can use our command-line PDFtk Server to export and import PDF bookmark data. PDFtk Server comes with our Windows application PDFtk Free. We also offer PDFtk Server installers for Mac, Red Hat and CentOS. Many Linux distributions offer a pdftk package you can install.

Export PDF bookmarks on the command-line like this:

pdftk C:\Users\Sid\Desktop\doc.pdf dump_data output C:\Users\Sid\Desktop\doc_data.txt

When using the Windows command-prompt, it helps to use drag-and-drop from the file manager: drag the input PDF file from the file manager onto the command-prompt, and its full pathname will appear at the prompt.

Import PDF bookmarks from a data file like this:

pdftk C:\Users\Sid\Desktop\doc.pdf update_info C:\Users\Sid\Desktop\doc_data.txt output C:\Users\Sid\Desktop\updated.pdf

The bookmark data file format was designed to be easy to parse and easy to generate. Here is an example of two bookmarks:

BookmarkTitle: PDF Reference (Version 1.5)
BookmarkLevel: 1
BookmarkPageNumber: 1
BookmarkTitle: Contents
BookmarkLevel: 2
BookmarkPageNumber: 3

For non-ASCII text, use HTML numerical entities, e.g.:

BookmarkTitle: Cubic Bézier Curves

For more examples of generating bookmark data and then importing it into a PDF, check out our article: Enjoy Photos on Nook or Kindle Using PDF Albums.

Article Author: Sid Steward

About PDF Labs

Our mission is to make PDF easier to use.

PDF Labs is operated by Sid Steward, author of PDF Hacks (O’Reilly) and the popular PDF Toolkit.

Please contact Sid Steward by email. Include PDF Labs in the subject to ensure prompt delivery:

About PDF Hacks

PDF Hacks Cover

"If you like pdftk, then you’ll appreciate the other 25 programs and scripts I created for my book, PDF Hacks." –Sid

About PDFtk

For ten years, power users have relied on PDFtk for server-side processing of PDF documents. Our command-line PDFtk has been — and always will be — free (as in freedom) software.

Today we also offer a convenient graphical application: PDFtk Pro. Your purchase of PDFtk Pro will help fund the continued development of our GPL PDFtk.

Thank you for your support!