tmccormi wrote on Wednesday, March 06, 2013:
IF you or your customer has been scanning PDF documents and they are producing files that are very large compared to generated PDFs then this script may be of assistance.
Example: XSANE scan using PDF mode at 200 DPI save this 38 page document:
49M 2013-03-06 10:21 original-20130305-MI2-signed.pdf
After compression
2.7M 2013-03-06 10:31 new-20130305-MI2-signed.pdf
Here follows a simple shell script, would be easy to make a window cmd file or a small php script… maybe even add a option for compress on upload to the document manager? Not sure if ghostscript is available for windows as a native binary thoough.
#!/bin/sh
# Compress a PDF file
echo Enter Original File Name
read INPUT
echo Enter New File Name
read OUTPUT
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${OUTPUT} ${INPUT}
ls -lh ${OUTPUT} ${INPUT}
echo HIT ENTER to rename new file back to original name
read X
rm ${INPUT}
mv ${OUTPUT} ${INPUT}
ls -lh ${INPUT}