I routinely print and scan stuff to PDF format. Both in Windows and Linux this produces pretty large files, usually in the 400+K range. In Windows, you can spend $199 plus shipping or tax for Adobe Acrobat Pro, which will both allow you to print to a PDF and then modify the output. In Ubuntu, I use the free cups-pdf package to print web pages and the like to PDF format. It relies on ghostscript (also free) which is usually installed by default but not always. To install both from the terminal:
sudo aptitude install cups-pdf ghostscript
This will add a printer to your system simply called PDF that will put its output files in a new PDF directory in your home folder. You can change that, of course.
In order to shrink the output file, I wrote a little bash script based on the help provided on this page. You can simple open GEdit, Kate, or another text editor, then copy and paste the following into the new file:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=”$OUTNAME” $1
mv ~/PDF/$OUTNAME ~/PDF/$1
The first block parses the file name passed to the script. The ‘gs’ command tells ghostscript how to reduce the file size, putting the result in a new file. The last block simply deletes the larger file and then renames the new, smaller PDF file to the original name. That’s all there is to it.
How well does it work? Well, I was able to reduce a 2.2 MB file printed from a web page down to 370K. Pretty effective.
As a side note, I tried to implement this script as a postprocessing step in the cups-pdf’s configuration file (/etc/cups/cups-pdf.conf), but no go after an entire afternoon of effort. Apparently Apparmor locks down CUPS and particularly cups-pdf pretty tightly, so they won’t communicate with an external script anymore without modifying the security settings. Pretty frustrating. If anybody has a fix that won’t overly compromise security (like turning off apparmor), please comment on this post.
In the meantime, I have a quick way to reduce PDFs down to manageable sizes in Ubuntu. Very cool. And free.