Printing PDF Bookmarks List

I work with PDF a lot, and it bothers me that I can see an outline view when I open the document, but I don’t seem to be able to grab just that view. My presentations are mostly PDF and the titles and section headings show up nicely. Today I figured out how to get an outline view, so I’m putting that information here while I remember how to do it!

I used a tool called pdftk which is excellent, I’ve used it before for doing various other PDF-related things. To grab metadata such as bookmarks, use the dump-data command, like this:

pdftk myfile.pdf dump_data | grep BookmarkTitle > outline.txt

The above line takes all the bookmarks from the PDF (this was a slide deck created using powerdot and LaTeX, the section and slide titles nest appropriately), and outputs a bunch of information about the document and the various PDFs. The grep command just gets the lines containing “BookmarkTitle”, then the whole thing gets written to a file. I cleaned that up and now I have the outline of my course, so I can add timings, notes for the exercises and so on.

2 thoughts on “Printing PDF Bookmarks List

  1. Hi Lorna, where is the text file saved, I can’t find it, or it didn’t actually do it. Are there no requirements for indicating source and output directories?

    • The textfile is at the very end of the command after the “>” – so in this example, the file is “output.txt” in the directory you ran the command from. Hope that helps.

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.