Split PDF via C++

Split PDF, HTML, TXT files. Use Aspose.PDF for C++ to modify PDF documents programmatically

Split Files Using Aspose.PDF for C++

Need just part of your large PDF files? To separate one or more parts from your PDF document, you must split the pages of the original PDF file. In order to split files, we’ll use Aspose.PDF for C++ API which is a feature-rich, powerful, and easy-to-use document manipulation API for cpp platform. Open NuGet package manager, search for Aspose.PDF and install. For more details please learn Documentation Pages. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF.Cpp

Split documents via C++


You need Aspose.PDF for C++ 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 C++

With the Aspose.PDF for C++ 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 - C++

This sample code shows how to split PDF file - C++

    // Read pdf file to Aspose Document
    doc = MakeObject<Document>(u"1.pdf");

    //Create PdfFileEditor object
    pdfEditor = MakeObject<Aspose::Pdf::Facades::PdfFileEditor>();

    //Split pdf file by half
    pdfEditor->Extract(pathSource, 1, doc->get_Pages()->get_Count() / 2, u"pdf_half.pdf");