3

I'm looking for a way to modify an existing pdf file so that the bookmarks panel opens automatically (on the right hand side) when I open the pdf file in acrobat reader or another reader.

In https://stackoverflow.com/questions/17333412/set-pdf-document-properties-initial-view you can see how this would be done in Acrobat.

However, I do not have, or really want Acrobat, and would like a way to do this from the unix command line.

I've looked at pdftk and qpdf but can't see how these tools can help me for the moment.

Any ideas ?

Best regards /Colm

  • https://superuser.com/questions/1186580/pdftk-pdfs-that-display-with-bookmark-panel-open Very similar request – carbontracking Oct 18 '17 at 08:53
  • So I'm looking for the metadata in which I should find the document properties, including the "Initial View" properties – carbontracking Oct 18 '17 at 08:54
  • http://exiftool.sourceforge.net/ seems to be another option. So far when I run this on a PDF that automatically displays the bookmarks, I don't see any metadata that seems to point to that. – carbontracking Oct 18 '17 at 10:13
  • There is a standalone windows tool that allows me to do exactly what I want http://www.evermap.com/autometadata.asp but it would be nice to have a unix/Cygwin command-line option – carbontracking Oct 18 '17 at 10:17
  • exiftool would be great if it could modify the PageMode tag but as shown on https://sno.phy.queensu.ca/~phil/exiftool/TagNames/PDF.html this is not writable by exiftool. – carbontracking Oct 19 '17 at 14:07
  • FYI : The PageMode tag needs to have the value UseOutlines in order to automatically display the bookmarks. This is deduced from modifying a pdf file using autometadata and comparing the exiftool output from both. – carbontracking Oct 19 '17 at 14:08

1 Answers1

2

Having done a comparison of the raw pdf files in a text editor I have a solution :

Replace the line

<</Type/Catalog/Pages 2 0 R/Lang(en-GB) /StructTreeRoot 32 0 R/Outlines 24 0 R/MarkInfo<</Marked true>>>>

with

<</PageMode/UseOutlines/Outlines 3 0 R/Pages 4 0 R/MarkInfo<</Marked true>> /Type/Catalog/Pages 2 0 R/Lang(en-GB) /StructTreeRoot 32 0 R/Outlines 24 0 R/MarkInfo<</Marked true>>>>

and now the bookmarks open automatically at opening.

It remains to see if this will work on different pdf files......

  • Thanks for finding the right tag, which pointed me in the right direction! You do not need to duplicate the other tags; you only need to add `/PageMode/UseOutlines` to the root object. However, by doing so, at least Adobe Reader will ask to save the file on every exit. The solution is to use Ghostscript; see this post: https://thechriskent.com/2017/03/06/setting-pdf-view-options-with-pdfmark/ – Klaidonis Oct 18 '20 at 07:44