PDF shrink

So you are a company that outsources business document templates design (invoices, whatever) and you are not able to make that PDF below 100KB as it should be.

Maybe you are at 500KB or 700KB. Who knows how much you are wasting on WORM disk. And IP traffic. Whatever you pain may be, I found a short solution for PDF shrinking.

This does not scale well, you can shrink ~2 PDFs per CPU/core. But it works and it's free if you can spare the CPU.

You will need a POSIX operating system (linux, bsd, macosx, maybe cygwin).
I did it with a Perl CGI to keep it simple enough.

Now the solution as it is. 

Let's say you have a web application that takes the PDF template and fills the fields with client data and outputs a final PDF to send to the client.
Before sending to the client, you POST it to the Perl CGI (or PHP script, or...) and save the resulting shrinked PDF.
This is the PDF you send to the client and archive on WORM disk or whatever long term storage you have.

The solution as a shell one liner:

cat bigpdf.pdf | pdftops - - | ps2pdf - - > smallpdf.pdf

Read the rest of this post »