Ubuntu: How to reduce the size of a pdf file?



Question:

I'm looking for a way in Ubuntu to reduce the size of a pdf (by reducing the quality of the images).

I know that this can be done in Ghostscript by typing the following command in terminal:

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

The problem is that I can't specify the quality with any accuracy. The parameter -dPDFSETTINGS=/screen is the one that decides the quality; but the alternatives are quite rigid (for example it is possible to do -dPDFSETTINGS=/ebook for slightly better quality).

I'm looking for a way to reduce the size of a pdf in a way that allows me to specify the desired quality numerically.


Solution:1

I was able to make a slight variation on your command successful using the -r300 option from @drN The -r option allows you to set the output resolution in the pdf as well as png.

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default \      -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages \      -dCompressFonts=true -r150 -sOutputFile=output.pdf input.pdf  


Solution:2

These two posts that I had posted on Stackoverflow should help you. I was trying to reduce the size of pdfs whilst ensuring that they met a certain dpi or ppi for my thesis.

Reducing size of pdf with ghostscript

Changing pdf image dpi using gs

Have you tried playing around with convert in Linux?

Edit:

gs \    -o out300.png \    -sDEVICE=pngalpha \    -r300 \     input.pdf  

If I remember correctly, r300 is the output dpi but you might want to check. This converts a pdf to a png, though.

OR

convert -units PixelsPerInch myPic.pdf -density 300 fileout.pdf  

Let us know how it goes! This is for a pdf or any other format to any other format. I just used an input file of myPic.pdf and an output file of fileout.pdf


Solution:3

The simplest way I found is to open source PDF file with LibreOffice Draw and then export to PDF with expected DPI. Export dialog window of Draw allows you to specify DPI and other options for exported PDF.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »