Search code examples
pdfghostscript

Display only first two levels of bookmarks in PDF using pdfMark/ghostscript


I'm using PDFtk to combine multiple pdf files and create bookmarks in the combined pdf file. When the combined pdf file is opened I want to display only first two levels of bookmarks (file has total three levels of bookmarks)

Solution using pdfmark+ghostscript suggested here displays all (level) bookmarks. https://unix.stackexchange.com/questions/398806/how-to-display-bookmarks-in-the-initial-view-when-opening-a-pdf-file https://thechriskent.com/2017/03/06/setting-pdf-view-options-with-pdfmark/

I went through pdfmark reference manual by Adobe but I did not find any options. I'm not an expert in pdfmark or ghostscript.

I have Windows and looking for a command line solution (process multiple files regularly). Thanks.


Solution

  • Try:

    cpdf -bookmarks-open-to-level <n> in.pdf -o out.pdf

    where <n> is 0 for top level, 1 for next level etc...