Mike
Mike

Reputation: 115

merging PDFs with Ghostscipt ignoring outline and using pdfmark instead

I am using a Batch script to merge different PDFs in one complete file.

 %gsc% -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dEPSFitPage -o  %dsk%%zus%%ext% %mfd% %pth%tmp\pdfmarks

 %dsk%%zus%%ext%: Path and name of final (complete) document

 %mfd%: Path and name of docs to be merged (c:\test\1.pdf c:\test\2.pdf ...)

 %pth%tmp = path to the pdfmarks file

Additionally, I am creating a pdfmark document inside the script which gs uses to create the bookmarks. But unfortunately, some of the docs I am merging, have already their own bookmarks and I did not yet find a solution how to ignore those. GS should only use the bookmarks inside the pdfmarks file.

How can this be done?

Upvotes: 2

Views: 468

Answers (1)

KenS
KenS

Reputation: 31141

Firstly; you are not 'merging' PDF files when you use Ghotscript's pdfwrite device. The process is described in detail here

The important point is that the way the input file(s) are constructed has no bearing on the way the output file is constructed. If any other software you use relies on the file being constructed in a particular fashion it may not work on the output PDF file.

The -dEPSFitPage switch only has any effect when the input is an EPS file. If you want to 'fit' PostScript or PDF files then you need to use -dPDFFitPage, -dPSFitPage or just -dFitPage. However, all of these rely on you first selecting a media size, and then preventing it being altered by setting -dFIXEDMEDIA. For EPS files you would more normally use -dEPSCrop which sets the media size to the EPS declared BoundingBox.

You can prevent the PDF interpreter reading the Outlines tree (which you are calling Bookmarks) and then creating a pdfmark from it to pass to the pdfwrite device by using the -dNO_PDFMARK_OUTLINES switch which oddly isn't documented, presumably an oversight.

Upvotes: 3

Related Questions