PDF Tools – List Named Destinations in a PDF

pdf

How can I list the named destinations in a PDF file?

Named destinations are the formal name for what you might call anchors. Major browsers jump to the named destination foo when you follow a link to http://example.com/some.pdf#foo.

I have documents where I can see anchors working, but I can't seem to find a way to list the anchors. Evince, okular and xpdf will jump to them when instructed but don't seem to have an interface that lists them. pdftk dump_data lists bookmarks, but that's not the same thing (that's table of content entries, which may well be at the same position as named destinations but can't be used as anchors).

I'm looking for a command line solution (suitable, for example, for use in a completion function after the likes of evince -n). Inasmuch as this is meaningful, I'd like to list the destinations in the order in which they appear in the document. Bonus: show the target page number and other information that helps figure out approximately where the destination is.

See also View anchors in a PDF document on Software Recommendations for a GUI viewer.

Best Answer

Poppler's pdfinfo command-line utility will provide you with page number, position, and name for all named destinations in a PDF. You need at least version 0.58 of Poppler.

$ pdfinfo -dests input.pdf
Page  Destination                 Name
   1 [ XYZ null null null      ] "F1"
   1 [ XYZ  122  458 null      ] "G1.1500945"
   1 [ XYZ   79  107 null      ] "G1.1500953"
   1 [ XYZ   79   81 null      ] "G1.1500954"
   1 [ XYZ null null null      ] "P.1"
   2 [ XYZ null null null      ] "L1"
   2 [ XYZ null null null      ] "P.2"
(...)
Related Question