Command line tricks: PDF editing



Command line tools: qpdf, mutool.


  • merge multiple PDF files
    qpdf --empty --pages input1.pdf input2.pdf -- output.pdf
    

  • extract pages 1-10 and drop metadata for the rest pages
    qpdf --empty --pages input.pdf 1-10 -- output.pdf
    

  • rotate all the pages for 90 degree
    qpdf input.pdf --rotate=+90 output.pdf
    

  • extract pages 1-10 (fonts and forms not supported)
    mutool convert -o output.pdf input.pdf 1-10
    

  • remove PDF password protection (need to know the password)
    mutool clean -p "myPassword" -D input.pdf output.pdf