• Case-insensitive search of a string in a PDF, thanks to pdfgrep:
$ pdfgrep --page-number --ignore-case 'my_string' ./document.pdf
  • Convert a PDF to a JPEG file at 150 dpi:
$ convert -density 150 ./document.pdf ./document.jpg
  • Extract images from a PDF document:
$ pdfimages -j document.pdf prefix
  • Compile all JPEG files in the current folder into a single PDF at 150 dpi:
$ convert -density 150 ./*.jpg ./document.pdf
  • Remove password of a PDF:
$ pdftk ./password-protected.pdf input_pw PROMPT output ./no-password.pdf
  • Split a PDF into pages:
$ pdftk doc.pdf burst
  • Merge 2 PDF documents:
$ pdftk doc1.pdf doc2.pdf cat output newdoc.pdf
  • Same as above, but for all PDFs of the current folder. This also have the nice side effect of removing all DRMs :) :
$ gs -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -q -sOutputFile=bigfile.pdf ./*
$ gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -q -o small-output.pdf large-input.pdf
  • Reduce a big.pdf file to a smaller.pdf file by limiting its images to 1000 pixels and convert them to grayscale:
$ pdfimages -j ./big.pdf prefix
$ convert -resize 1000x1000 -type Grayscale -density 150 ./prefix-*.jpg ./smaller.pdf
$ rm prefix-*.jpg

Additional References