I'd like to concatenate pdf documents without loosing any information (image resampling etc.). I only want to do lossless compressions, consolidate fonts etc.
Before merging, I'd like to remove the first and last page of each document. How can I combine this with the merging process, so that I don't need to run each file twice through gs?
To merge, I use the command from this excellent answer. I added dPDFSETTINGS=\prepress. I am not sure if this is necessary or a good idea.
gs \ -o book.pdf \ -sDEVICE=pdfwrite \ -dPDFSETTINGS=/prepress \ -dColorConversionStrategy=/LeaveColorUnchanged \ -dEncodeColorImages=false \ -dEncodeGrayImages=false \ -dEncodeMonoImages=false \ title.pdf \ content.pdf
I tried the command above (without removing pages) on some real life files, and it is running very slowly.
gswin32c.exe -dBATCH -dNOPAUSE -o temp.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dColorConve rsionStrategy=/LeaveColorUnchanged -dEncodeColorImages=false -dEncodeGrayImages=false -dEncodeMonoImages=false [list of pdf files] pdfmark
Running the above command for 20 2MB files creates nearly 2 GB temp files and then runs extremely slowly with little CPU utilization and a lot of HDD activity. It takes about 20 min, and the output file is 800 MB large.
I get this error message: GPL Ghostscript 9.10: Missing glyph CID=0, glyph=0028 in the font HiddenHorzOCR . The output PDF may fail with some viewers.
On the other hand, pdftk runs in 30s, and the output file is 40 MB. Adding the bookmarks with gs takes another minute and slims the file to 30 MB.
gswin32c.exe -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=out.pdf pdftk.pdf pdfmark
Is there any downside to using pdftk? I would like to preserve the images in exactly the same quality and not loose any details and not make the files unnecessarily large. Otherwise I don't care too much, the pdfs are mostly scanned scientific articles and book chapters. The pages that I would like to remove are cover pages that were scanned with each article, one in the front and one at the end.