7

I'm looking for a Linux command line util that inputs a merged PDF (between 1mb and 500mb) and outputs an optimized/linearized version. Each and every page uses the same set of ~8 images, and the same font. Running one of my test files through Adobe Acrobat Pro took the file from 34MB to 1.6MB in a matter of about 30 seconds. I'm not really expecting performance like that, but something even half as fast/efficient would be wonderful.

I need it for a batched job running on Linux, which is why it needs a CLI. I've tried pdftk, gs, qpdf, pdftops, and pdfsizeopt. The first 4 are either far too slow or don't fully optimize the pdf files. pdfsizeopt seems promising, but I'm having trouble with consistency -- some of my pdfs will work, others will throw errors.

Any ideas other than what I've already listed? I wouldn't even mind purchasing something if it did the job.

  • Linearization and file size are not directly related... can you clarify precisely what you want? – yms Jun 17 '14 at 19:00
  • @Alec Sanger: If my answer was helpful to you, then please consider marking it as the accepted answer so others may more easily find it in the future. This is also a polite way to thank the person answering your question for helping you out. – Andrea Lazzarotto Jan 7 '17 at 19:08
3

I personally use Ghostscript to optimize the size of my PDF files. You can specify an optimization level and it will shrink the pictures. This also has the (IMHO desirable) side-effect of removing elements that are outside the page margins.

gs -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -r75 -dNOPAUSE -dQUIET -dBATCH -sOutputFile="output.pdf" "input.pdf"

The levels you can use are:

-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.