Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →To split a PDF with Python, copy the page or page range you want into a new document, then save it. PyMuPDF’s Document.insert_pdf() provides a direct way to do this; its page indexes start at 0. For another option, pypdf can append a selected range using a start-inclusive, stop-exclusive tuple.
Extract a page range with PyMuPDF
PyMuPDF’s Document.insert_pdf() copies pages from one PDF document into another. The example below extracts pages 3 through 7 using ordinary, 1-based page numbers, with both endpoints included.
As an Amazon Associate I earn from qualifying purchases.
from pathlib import Path
import pymupdf
source_path = Path("input.pdf")
output_path = Path("selected-pages.pdf")
# User-facing page numbers are 1-based and inclusive.
first_page = 3
last_page = 7
with pymupdf.open(source_path) as source:
if first_page < 1 or last_page < first_page or last_page > source.page_count:
raise ValueError("Page range is outside the document")
output = pymupdf.open()
output.insert_pdf(
source,
from_page=first_page - 1,
to_page=last_page - 1,
)
output.save(output_path)
output.close()
Change input.pdf, the output filename, and the two page numbers for your files. The range check rejects a start below page 1, an end before the start, or an end beyond the document. PyMuPDF indexes pages from 0, so subtract 1 from both user-facing page numbers. Its to_page endpoint is inclusive: the converted last-page index is copied too. See the PyMuPDF tutorial on merging and splitting PDFs.
Recommended Free Tools
Split into one PDF per page
To create a separate output for every page, iterate over the source indexes, create an empty document for each one, and insert only that page. This example names the files using 1-based page numbers.
#1 Best Overall
from pathlib import Path
import pymupdf
source_path = Path("input.pdf")
output_dir = Path("pages")
output_dir.mkdir(exist_ok=True)
with pymupdf.open(source_path) as source:
for index in range(source.page_count):
output = pymupdf.open()
output.insert_pdf(source, from_page=index, to_page=index)
output.save(output_dir / f"page-{index + 1}.pdf")
output.close()
Split into fixed-size chunks
For chunks of a chosen number of pages, advance by that size and cap the last chunk at the source’s final page. The example creates chunks of five pages, except when fewer remain.
from pathlib import Path
import pymupdf
source_path = Path("input.pdf")
output_dir = Path("chunks")
chunk_size = 5
output_dir.mkdir(exist_ok=True)
with pymupdf.open(source_path) as source:
for start in range(0, source.page_count, chunk_size):
end = min(start + chunk_size, source.page_count)
output = pymupdf.open()
output.insert_pdf(source, from_page=start, to_page=end - 1)
output.save(output_dir / f"chunk-{start // chunk_size + 1}.pdf")
output.close()
Here, start and end are zero-based indexes, and end is exclusive in the loop’s arithmetic. The conversion to to_page=end - 1 is needed because PyMuPDF’s to_page endpoint is inclusive.
Rank #2
Use pypdf if it fits your project
pypdf offers a different range convention through PdfWriter.append(). Its page tuple uses zero-based indexes with an exclusive stop value: (2, 7) selects indexes 2 through 6, or pages 3 through 7 in ordinary numbering.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
from pypdf import PdfWriter
writer = PdfWriter()
writer.append("input.pdf", pages=(2, 7))
writer.write("selected-pages.pdf")
Consult the pypdf guide to merging PDFs and its PdfWriter.append() API reference for the documented selection and write methods. The two libraries use different endpoint conventions; do not transfer a range unchanged between the examples.
Quick Recap
Best Value
Check the result
- Confirm the requested range is within the source document’s page count before splitting.
- Open the generated PDF files and check that the expected first and last pages are present.
- For one-file-per-page or chunk output, confirm the output directory contains the expected files and that the final chunk is not empty.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




