Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pdftk compression option

I use pdftk to compress a pdf using the following command line

pdftk file1.pdf output file2.pdf compress 

It works as the weight of my file decreased.

Are there [options] to change the compression???

Or maybe other solutions to compress my file? It is heavy because some graphics have a lot of points. Is there a way to convert these graphs to jpg for instance and adapt the compression?

like image 765
RockScience Avatar asked Mar 14 '11 09:03

RockScience


People also ask

How do I compress a scanned PDF?

Click the Select a file button above or drag and drop files into the drop zone. Select the PDF file you want to make smaller. After uploading, Acrobat will automatically reduce the PDF size. Sign in to download or share your compressed PDF.


1 Answers

I had the same problem and found two different solutions (see this thread for more details). Both reduced the size of my uncompressed PDF dramatically.

  • Pixelated (lossy):

    convert input.pdf -compress Zip output.pdf 
  • Unpixelated (lossless, but may display slightly differently):

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

Edit: I just discovered another option (for lossless compression), which avoids the nasty gs command. qpdf is a neat tool that converts PDFs (compression/decompression, encryption/decryption), and is much faster than the gs command:

qpdf --linearize input.pdf output.pdf 
like image 85
nullglob Avatar answered Sep 18 '22 15:09

nullglob