Categorías
hoy aprendí ...

… a optimizar un PDF con GhostScript en linux

Resulta que escannee unas páginas con XSane y me genera imágenes en 300 DPI, contatenando todas las ellas en un PDF.

El PDF quedó de 97Mb, pero quería achicar el tamaño reduciendo los DPI a 150. Encontré esto y me ayudó

http://tuxdiary.com/2015/04/07/compress-pdf-files-linux/

Copio el contenido por si algún día desaparece de la web

Compress PDF files on Linux

pdf

The major benefit of PDF documents is the intended representation remains almost same on any operating system or device. However, scanned PDFs can be of large sizes and you may need to optimize or reduce the size of the file to share it with a friend. This article discusses several ways to do that on Linux with near-original quality.

Native solutions

  • Ghostscript is a great tool for compressing PDFs. In our tests it delivered the best compression ratio. Simply run: $ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf in.pdf
  • -dPDFSETTINGS can be any of:
    /screen : low-resolution output, lowest output size
    /ebook : medium-resolution output, medium output size
    /printer OR /prepress : high-resolution with maximum output size
  • Run the Shrinkpdf script: $ ./shrinkpdf in.pdf out.pdf The script is almost same as the explicit gs command above. However, it has one advantage – it does an output file size check.
  • qpdf:  A cmdline program that does structural, content-preserving changes to PDF files. The simplest way to invoke it: $ qpdf –linearize input.pdf output.pdf However, this didn’t provide a very optimized output in our tests.
    To install qpdf on Ubuntu, run: $ sudo apt-get install qpdf
  • smpdf is a commercial closed source tool. However, there is an evaluation copy available for download which adds an unlicensed version mark to the modified document. Usage: $ smpdf in.pdf -o out.pdf

Posted on Author John SonmezCategories HACKS/UTILSTags compression tool, useful cli tools