WebSubmit: preserve bookmarks when stamping PDF files
|Reported by:||jcaffaro||Owned by:|
The WebSubmit file stamper relies on the pdftk tool to process PDF files, but unfortunately pdftk does not preserve bookmarks (eg. table of content or "outlines"), even though it is able to dump them.
Ghostscript could be used instead to stamp files, as it can preserve such information.
Ghostscript could fully replace pdftk in this case, or could be used simply to enrich the resulting stamped file with the necessary instructions to create the bookmarks (PDFMark?), provided that these instructions can be extracted correctly from the original file.
Some additional untested information:
$ pdftk original_file.pdf dump_data InfoKey: Creator InfoValue: LaTeX with hyperref package NumberOfPages: 88 BookmarkTitle: Introduction BookmarkLevel: 1 BookmarkPageNumber: 9 BookmarkTitle: Context BookmarkLevel: 2 BookmarkPageNumber: 9 BookmarkTitle: CERN BookmarkLevel: 3
$ pdftk stamped_file.pdf update_info original_file.info output new_stamped_file (does not seem to add the necessary information unfortunately)
$ gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -o stamped_file.pdf original_file.pdf stamp.pdf (would apparently merge the two files and keep the bookmarks from both)
$ gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -o new_stamped_file.pdf \ -c "[/Page 1 /View [/XYZ null null null] /Title (Title 1) /OUT pdfmark" \ -c "[/Page 2 /View [/XYZ null null null] /Title (Title 2) /OUT pdfmark" \ -f stamped_file.pdf (would apparently add the specified bookmarks instructions to the given file. They should be extracted from the original file, and cleaned for this syntax)
In any case one should be careful if bookmarks are linking to absolute page numbers, as the number of pages can change when adding a cover page. This would probably not be handled by Ghostscript.