Friday, 18 April 2025

Change pdf filesize

This option changes the resolution of the output file in ghostscript.

-dPDFSETTINGS=/screen

So, for example

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -sOutputFile=output.pdf file1.pdf file2.pdf

Options are:

  • screen (72 dpi)
  • ebook (150 dpi
  • printer (300 dpi)

UPDATE

Needing higher quality images, the following approximately doubles the filesize compared to /printer, but still only a third of the original file size.

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH -dQUIET -dPDFSETTINGS=/printer -dColorImageDownsampleType=/Average -dGrayImageDownsampleType=/Average -dMonoImageDownsampleType=/Subsample -dColorImageResolution=600 -dGrayImageResolution=600 -dMonoImageResolution=600 -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/DCTEncode -dGrayImageFilter=/DCTEncode -dDCTEncodeQuality=90 -dSubsetFonts=true -dEmbedAllFonts=false -sOutputFile=out.pdf file1.pdf file2.pdf

To modify, tweak some options, especially resolution and quality

No comments:

Post a Comment