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

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:

BookmarkBegin
BookmarkTitle: PDF Reference (Version 1.5)
BookmarkLevel: 1
BookmarkPageNumber: 1
BookmarkBegin
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