A simple CLI tool that I made for myself using PyPDF that allows me to manipulate and merge PDF files using Python list-like indexing.
If you want to use it, you can clone the repository and install it locally using pip:
git clone https://github.com/iafelipe/pdf_list.git
cd pdf_list
pip install .
usage: pdf_list [-h] [-o OUTPUT] filename[index] [filename[index] ...]
Manipulate and merge PDF files using Python list-like indexing.
indexing options:
[start:stop:step]
[start:stop]
[start:]
[:stop]
[::step]
[index1,index2,...] - no spaces
[:], [] or no index (all pages)
note: 0-based indexing and exclusive stop
positional arguments:
filename[index] pdf file(s) with index (file extension is optional)
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT Output file name (default: out.pdf)
Concatenate all pages of file1.pdf and file2.pdf into a single file:
pdf_list file1.pdf file2.pdf
Concatenate the first 3 pages of file1.pdf and the second page of file2.pdf into a single file:
pdf_list file1.pdf[:3] file2.pdf[1]
Select the last page of file1.pdf and save it as last_page.pdf:
pdf_list file1.pdf[-1] -o last_page.pdf
Select the first and last pages of file1.pdf and save it as first_last.pdf:
pdf_list file1.pdf[0,-1] -o first_last.pdf
Create a copy of file1.pdf and save it as copy.pdf:
pdf_list file1.pdf -o copy.pdf
Depending on your system, you may need to separate the file[index]
with quotes:
pdf_list "file1.pdf[:3]" "file2.pdf[1]"