#Linux One-liners to manage pdf documents
Merge many .jpg files into one pdf
convert *.jpg doc.pdf
Set a password
pdftk file.pdf output file_pw.pdf userpw PROMPT
UnSet a password (two options)
pdftk file_pw.pdf output file.pdf user_pw MYPASSWD
qpdf --password=MYPASSWD --decrypt crypt.pdf de_crypt.pdf
Remove pages
pdftk old.pdf cat 1-9 15-end output new.pdf
Merge many docs
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
Reduce doc size
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH ->sOutputFile=output.pdf input.pdf
The option
/screen
defines the most quality degree and size reduction factor.
Here the complete list of options from low to high quality:/screen
,/default
,/ebook
,/printer
,/prepress
.
typo in "Reduce doc size" line (->sOu), here below the correct one:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Do you need pdftk installed on machine or is pdftk pre-installed across many distros?
Mostly you have to install it by yourself as I've done on my Debian.