Split a PDF and Extract Pages

IronPDF for Python can split a PDF document into multiple separate files by copying specific pages or page ranges from the original document.

Getting Started

Create or load a multi-page PdfDocument, then use CopyPage to extract a single page or CopyPages to extract a range of pages. Each call returns a new PdfDocument containing only the specified pages, which can then be saved independently.

Understanding the Code

  • RenderHtmlAsPdf(html): Renders a multi-page HTML document (using page-break-after: always to create page breaks) into a PdfDocument.
  • CopyPage(index): Returns a new single-page PdfDocument containing the page at the given zero-based index. In the example, index 0 extracts the first page.
  • CopyPages(start, end): Returns a new PdfDocument containing the pages from start to end (inclusive, zero-based). In the example, indexes 1 and 2 extract pages 2 and 3.
  • SaveAs(path): Saves each resulting document to its own file.

Zero-Based Indexing

IronPDF uses zero-based page indexing throughout its API. Page 1 of a document is at index 0, page 2 is at index 1, and so on.

Learn to merge and split PDFs with IronPDF for Python!

Ready to Get Started?
Version: 2026.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.