23 February 2026

How to shrink file size of a pdf file?

sudo apt update
sudo apt install ghostscript

The Compression Command
Use the following command to compress the PDF to a "screen" quality, which is usually sufficient for viewing on monitors or emailing and will easily bring a 3MB file below 2MB:
bash
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE 
-dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
  • input.pdf: Replace with your original file name.
  • output.pdf: The name of the new compressed file.
Alternative: Better Quality (eBook)
If the /screen setting makes the text look too blurry, try /ebook (150 dpi), which balances good quality with a smaller file size:
bash
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE 
-dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Other Options
  • -dPDFSETTINGS=/screen: 72 dpi, lowest quality, smallest size (best for >2MB requirement).
  • -dPDFSETTINGS=/ebook: 150 dpi, medium quality, better for reading.
  • -dPDFSETTINGS=/printer: 300 dpi, high quality, likely to keep the file over 2MB.
Note: If the PDF contains text only, the file size reduction may be limited.


No comments:

Post a Comment