Required tools: gs (ghostscript), qpdf, pdfseparate, pdftoppm.
Reduce the size of a scanned PDF, the value for "quality" option can be:
screen,ebook,printer,prepress
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/{quality} -dNOPAUSE -dQUIET -dBATCH -sOutputFile={output.pdf} {input.pdf}
Merge multiple PDF files:
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE={output.pdf} -dBATCH {input1.pdf} {input2.pdf}
Remove password:
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPDFPassword={password} -f -sOutputFile={output.pdf} {input.pdf}
qpdf --password={password} --decrypt {input.pdf} {output.pdf}
Extract pages from a PDF file:
pdfseparate -f {first page} -l {last page} {input.pdf} {output.pdf}
Convert a PDF file to images; define horizontal and vertical DPI to generate the images, 150 is the default value if dpi not specified.
pdftoppm -png -rx {horizontal dpi} -ry {vertical dpi} {input.pdf} {output prefix}
# If document.pdf has two pages
pdftoppm -png document.pdf img
# Will produce img-1.png, img-2.png
pdf linux