Skip to main content

pdftools

  • Copyright (c) 2015 Stefan Lehmann
  • License: MIT
  • Description: Python-based command line tool for manipulating PDFs. It is based on the PyPdf2 package.

Build Status PyPI version Downloads Downloads

Features

  • add, insert, remove and rotate pages
  • split PDF files in multiple documents
  • copy specific pages in a new document
  • merge or zip PDF files into one document

Usage

pdftools adds some scripts to your existing Python installation that can be called via the command line. The description for each script is listed below.

pdftools

usage: pdftools [-h] [-V] <command> ...

Python-based command line tool for manipulating PDFs. It is based on the
PyPdf2 package.

optional arguments:
  -h, --help     show this help message and exit
  -V, --version  Print version number and exit (default: False)

Sub-commands:
  <command>
    add          Add pages from a source file to an output PDF file
    copy         Copy specific pages of a PDF file in a new file
    insert       Insert pages of one file into another
    merge        Merge the pages of multiple input files into one output file
    remove       Remove pages from a PDF file
    rotate       Rotate the pages of a PDF files by 90 degrees
    split        Split a PDF file into multiple documents
    zip          Python-like zipping (interleaving) the pages of two documents
                 in one output file

Add

usage: pdftools add [-h] [-p PAGES [PAGES ...]] [-o OUTPUT] dest src

Add pages from a source file to an output PDF file

positional arguments:
  dest                  Destination PDF file
  src                   PDF source file

optional arguments:
  -h, --help            show this help message and exit
  -p PAGES [PAGES ...], --pages PAGES [PAGES ...]
                        list of pages to add to the output. Examples: 5; 1-9;
                        1-; -9 (default: None)
  -o OUTPUT, --output OUTPUT
                        Name of the output file. If None, the `dest` file will
                        be overwritten (default: None)

Copy

usage: pdftools copy [-h] [-o OUTPUT] [-p PAGES [PAGES ...]] [-y] src

Copy specific pages of a PDF file in a new file

positional arguments:
  src                   Source PDF containing pages to copy

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Name of the output file. If None, the `dest` file will
                        be overwritten (default: None)
  -p PAGES [PAGES ...], --pages PAGES [PAGES ...]
                        list of pages to copy in the new file. Examples: "5 8
                        10": Pages 5, 8, 10; "1-9": Pages 1 to 9; "5-": Pages
                        from 5 to last page; "-9": Pages from beginning to 9
                        (default: 1)

Insert

usage: pdftools insert [-h] [-o OUTPUT] [-p PAGES [PAGES ...]] [-i INDEX]
                       dest src

Insert pages of one file into another

positional arguments:
  dest                  Destination PDF file
  src                   Source PDF file

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Name of the output file. If None, the `dest` file will
                        be overwritten (default: None)
  -p PAGES [PAGES ...], --pages PAGES [PAGES ...]
                        List of page numbers (start with 1) which will be
                        inserted. If None, all pages will be inserted
                        (default). Examples: 5; 1-9; 1-; -9 (default: None)
  -i INDEX, --index INDEX
                        Page number (1-indexed) of destination file where the
                        pages will be inserted. If None they will be added at
                        the end of the file (default: None)

Remove

usage: pdftools remove [-h] [-o OUTPUT] src pages [pages ...]

Remove pages from a PDF file

positional arguments:
  src                   PDF source file
  pages                 List of pages to remove from file. Examples: 5; 1-9;
                        1-; -9

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Name of the output file. If None, the `src` file will
                        be overwritten (default: None)

Rotate

usage: pdftools rotate [-h] [-d {90,180,270}] [-c] [-p PAGES [PAGES ...]]
                       [-o OUTPUT]
                       src

Rotate the pages of a PDF file by a set number of degrees

positional arguments:
  src                   Source file

optional arguments:
  -h, --help            show this help message and exit
  -d {90,180,270}, --degrees {90,180,270}
                        Specify degrees value to rotate page(s) (default: 90)
  -c, --counter-clockwise
                        Rotate pages counter-clockwise instead of clockwise,
                        by default (default: False)
  -p PAGES [PAGES ...], --pages PAGES [PAGES ...]
                        List of page numbers which will be rotated. If None,
                        all pages will be rotated. Examples: 5; 1-9; 1-; -9
                        (default: None)
  -o OUTPUT, --output OUTPUT
                        Output filename. If None, the source file will be
                        overwritten (default: None)

Split

usage: pdftools split [-h] [-o OUTPUT] [-s STEPSIZE]
                      [-q SEQUENCE [SEQUENCE ...]]
                      src

Split a PDF file into multiple documents

positional arguments:
  src                   Source file to be split

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Output filenames. If None, will append page numbers to
                        the input file name. (default: None)
  -s STEPSIZE, --stepsize STEPSIZE
                        How many pages are packed in each output file
                        (default: 1)
  -q SEQUENCE [SEQUENCE ...], --sequence SEQUENCE [SEQUENCE ...]
                        Sequence of numbers describing how many pages to put
                        in each outputfile (default: None)

Merge

usage: pdftools merge [-h] [-o OUTPUT] [-d] src [src ...]

Merge the pages of multiple input files into one output file

positional arguments:
  src                   List of input source files

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        Output filename (default: merged.pdf)
  -d, --delete          Delete source files after merge (default: False)

Zip

usage: pdftools zip [-h] [-d] [-r] src1 src2 output

Python-like zipping (interleaving) the pages of two documents in one output
file

positional arguments:
  src1          First source file
  src2          Second source file
  output        Name of the output file

optional arguments:
  -h, --help    show this help message and exit
  -d, --delete  Delete source files after merge (default: False)
  -r, --revert  Revert the pages of second input file (default: False)

Release files for pdftools 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdftools 2.0.2
File Size Uploaded
pdftools-2.0.2.tar.gz 10.6 kB Details

Release files / pdftools-2.0.2.tar.gz

Download URL pdftools-2.0.2.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b67251589a3e7f83cf0a3d9e159351cf0785f1de39f7b98fd194cef484b031a6
BLAKE2b-256 checksum
How to use checksums
f32236980836bd7277a86eed829b1638ef64c872ab3d5bcc699f825e5c743c40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1.post20200622 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

Release history Release notifications | RSS feed

This release

2.0.2 This release

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.1

2 release files

1.1.0

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page