PDF management

Compress PDF with ghostscript

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Even smaller -dPDFSETTINGS=/ebook:

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Merge many PDF files into one

pdftk *.pdf output all.pdf

Merge multiple images into A4 PDF

pdfjoin --a4paper --fitpaper false --rotateoversize false scan*.png

More information on pdfjoin here. Install pdfjoin as part of texlive-extra-utils:

sudo apt install texlive-extra-utils