I have two pdf files, one with bookmarks, and the other without.
I would like the second pdf file to have the same bookmarks as the first. I wonder how to do that using
gs? Ideally, it will be nice to first extract the bookmarks from the first pdf file into a text file (which is editable if I can learn its format), and then add the text file as bookmarks to the second pdf file.
I know how to add bookmarks in
pdfmarks format to a pdf file by
gs, from http://blog.tremily.us/posts/PDF_bookmarks_with_Ghostscript/
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=out.pdf in-*.pdf pdfmarks
But I don't know how to extract bookmarks from a pdf directly into
p.s.: In case you may wonder what bookmarks are, they are table of contents which can be shown in a side panel of a pdf reader (such as Evince (note: in Evince bookmarks are called index)), and when you click one bookmark, it will take you to the page.