pdfcli

A tool for manipulating pdf files from the command line.

Installation

pip install pdfcli

Merging

>>> pdfcli merge test_files/PDF1.pdf test_files/PDF2.pdf
>>> ls
PDF1.pdf        PDF2.pdf        PDF3.pdf        out.pdf
>>> pdfcli merge PDF1.pdf PDF2.pdf PDF3.pdf -o MergedPDFS.pdf
>>> ls
PDF1.pdf        PDF2.pdf        PDF3.pdf        MergedPDFS.pdf

Reordering

# Reversing the pdfs
>>> pdfcli reorder test_files/PDF1.pdf --reverse
#  Reordering based on page number
>>> pdfcli reorder test_files/MultiPagePDF.pdf --order=3,1,2

Deleting

# Delete third page, keep others
>>> pdfcli delete test_files/MultiPagePDF.pdf 3

Splitting

>>> pdfcli split test_files/MultiPagePDF.pdf 1
Split test_files/MultiPagePDF.pdf at index 1 into out1.pdf and out2.pdf

Rotating

# Clockwise Rotation
>>> pdfcli rotate test_files/MultiPagePDF.pdf clockwise
Pages were rotated clockwise successfully and saved at out.pdf

# Counter-Clockwise Rotation
>>> pdfcli rotate test_files/MultiPagePDF.pdf counter-clockwise
Pages were rotated counter-clockwise successfully and saved at out.pdf

Encrypting

# Can specify encryption key as option or environment variable PDFCLI_KEY
>>> pdfcli encrypt test.pdf --key=oli123 --out encrypted.pdf
PDF was successfully encrypted and saved at encrypted.pdf

Decrypting

# Can specify decryption key as option or environment variable PDFCLI_KEY
>>> pdfcli decrypt test.pdf --key=oli123 --out decrypted.pdf
PDF was successfully decrypted and saved at decrypted.pdf

Help

>>> pdfcli --help
Usage: pdfcli.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  decrypt  Decrypts a PDF file given a key.
  delete   Delete pages in a PDF.
  encrypt  Encrypts a PDF file given a key.
  merge    Merge a set of PDF files together.
  reorder  Reorder the pages in a PDF.
  rotate   Rotate a PDF file clockwise or counter-clockwise.
  split    Split a PDF file into two.