PDF Command line examples

These is just a bunch of Linux commands to manipulate PDF files:

  • Check PDF image details:
    pdfimages -list your_file.pdf
  • Check PDF metadata:
    pdfinfo file.pdf
  • Convert one page of a PDF to PNG:
    magick input.pdf[1] output.png

    This converts page #2 (the index is zero based) to output.png.

  • Concatenate PDFs:
    pdfunite file1.pdf file2.pdf file3.pdf ... fileN.pdf output.pdf
  • Render a manual page as a PDF
    pdfman manpg
  • Extract single pages from a pdf
    pdfseparate sample.pdf sample-%d.pdf

    extracts all pages from sample.pdf, if i.e. sample.pdf has 3 pages, it produces:

    sample-1.pdf, sample-2.pdf, sample-3.pdf
  • Convert PDF to SVG
    pdftocairo -svg input.pdf output.svg

These commands require the following tools to be installed: