Split PDF via Aspose.PDF for Python via C++

Utilize Aspose.PDF to split documents.

Split files using Aspose.PDF for Python via C++

In order to split files, we’ll use Aspose.PDF API which is a feature-rich, powerful and easy-to-use document manipulation API for python-cpp platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console. Our software tool also provides developers to split Word, PDF, HTML, TXT, and DOCX documents into parts. For more details please learn Documentation Pages.

Split documents via Python


You need Aspose.PDF library to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Create a new Document class object to split PDF pages.
  3. Add current page to the document.
  4. Save current page as a separate PDF

How to split PDF using Python

With the Aspose.PDF library, you can split large PDF documents. Splitting a PDF document is a common use case when working with PDF documents. It helps reduce the size of a PDF file by breaking large documents into smaller files to send via email.

Split PDF - Python

This sample code shows how to split PDF file - Python

import AsposePDFPythonWrappers as apw

document = apw.Document("sample.pdf")

pageCount = 1

for page in document.pages:
    newDocument = apw.Document()
    newDocument.pages.add(page)
    newDocument.save("page_" + pageCount + "_out" + ".pdf")
    pageCount += 1