This package splits a PDF file into multiple PDF files. It allows the user to extract specific page ranges from a PDF and provides a very basic output file formatter.
$ git clone https://github.com/elvout/pdfsplit.git
$ cd pdfsplit
$ pip3 install [--user] [--upgrade] .
This should install pdfsplit
into:
/usr/local/bin
if--user
is not provided topip3
.~/.local/bin
if--user
is provided topip3
(Linux).~/Library/Python/3.[x]/bin
if--user
is provided topip3
(macOS).
pdfsplit [-h] [-o offset] infile pagefile out_fmt
infile
: the filename of the PDF file to split.pagefile
: a text file containing 1-indexed page ranges to extract.out_fmt
: a Python f-string containing a formatting recipe for the filenames of output PDF files. The f-string should use an integer_i
representing the line number of each interval inpagefile
.- This executes arbitrary Python code. Use with caution.
offset
: the number of leading pages in theinfile
PDF to skip.
See sample/ for an example usage.
Each line of the pagefile
should contain one space-delimited page
number range. The ranges should be 1-indexed. Ranges are inclusive
of the starting number and exclusive of the ending number.
e.g.
1 15
15 42
42 67
70 75
If a line contains only the starting point of the range, the parser will set the endpoint of the range to the starting point of the next range if it exists.
The previous example is thus equivalent to:
1
15
42 67
70 75
as well as
1
15
42 67
70
75