A simple Python script that can:
- Split large PDFs into smaller PDFs (default: 30 pages per file).
- Delete selected pages from a PDF.
For example:
- Splitter: A 60-page PDF can be split into two 30-page files.
- Deleter: User input
1-10, 15-17will remove those pages from the PDF.
- Splits any PDF into chunks of custom page length (default: 30).
- Automatically names output files (
_part1,_part2, etc.). - Saves the new PDFs in the same directory as the original file.
- Supports long file names and complex paths (e.g.,
C:\Users\...).
- Deletes selected pages from a PDF based on user input.
- Automatically names output files (
[file name]_updated.pdf). - Saves the new PDFs in the same directory as the original file.
- Supports long file names and complex paths (e.g.,
C:\Users\...).
The script uses the PyPDF2 library to:
- Read the input PDF.
- Count the total number of pages.
- Split the PDF into smaller files (for the splitter) or remove selected pages (for the deleter).
- Save the resulting PDFs in the same folder as the original file.
Make sure you have Python 3.7+ installed and install the required library:
pip install PyPDF2- Clone or download this repository.
- Place your PDF file in a convenient folder.
- Run the relevant script. E.g.,
python PDFsplitter.py-
When prompted:
- For splitting: Enter the full path to your PDF.
- For deleting pages: Enter the full path to your PDF and the pages to delete in a format like
1-10, 15, 18-20.
If your PDF has 65 pages and you split by 30 pages:
myfile_part1.pdf (pages 1–30)
myfile_part2.pdf (pages 31–60)
myfile_part3.pdf (pages 61–65)
If you delete pages 1-10, 15, 18-20 from a PDF called myfile.pdf:
myfile_updated.pdf (all pages except 1-10, 15, 18-20)
- PDF pages are 1-indexed when entering ranges.
- Make sure your input format for deleting pages is comma-separated with optional ranges (
start-end). - The original PDF is not modified; a new PDF is created.