Read more

Compress bitmap images within PDF files

Thomas Eisenbarth
May 28, 2012Software engineer at makandra GmbH

Embedding bitmap images within PDF sometimes results in large files because the bitmaps are not compressed. If you don't need high quality images within the resulting PDF file, you can use ghostscript to compress embedded images:

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=new-smaller-file.pdf large-original-file.pdf
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Note that your PDF printer (or similiar generation tools) also often come with a compression setting for embedded raster images.

You can put this snippet into your ~/.bash_aliases:

alias pdf_compress='_compress(){ ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$1".c.pdf "$1";}; _compress'

Reload aliases (source ~/bash_aliases) and you can simply use pdf_compress example.pdf on your commandline.

Posted by Thomas Eisenbarth to makandra dev (2012-05-28 15:57)