On Fri, Jan 07, 2022 at 12:29:06PM +0000, Bev Nicolson wrote:
How do I reduce the size of a pdf without a) meaning I have to unzip to read it or b) shrinking it so the pages appear blank? I doubt I'll need to do this often but I'd welcome some pointers. Ghostscript is installed. I have just tried one option found by googling and got the second result. Not ideal.
I have a bash script as follows which compresses PDF, asking first if you want to bother given the amount of compression:-
#!/bin/bash # # # Compress PDF files using ghostscript # for i in "$@" do gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=/tmp/temp. pdf "$i" echo -n "$i compresses from " echo -n $(du -skh "$i" | cut -f 1 -d ' ' ) echo -n " to " du -skh /tmp/temp.pdf | cut -f 1 -d ' ' read -n1 -p "C[ompress], S[kip] or Q[uit]:" r case $r in q|Q ) echo;echo exit ;; c|C ) cp /tmp/temp.pdf "$i" ;; s|S|* ) ;; esac echo;echo done