PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2005/2008/2010/2012/2013

How To Split PDF Documents Using PDFOne .NET

Learn how to split and reorganize PDF documents using PDFOne .NET and C#.
By V. Subhash

In this article, we focus on how to split PDF documents. The PDFDocument of PDFOne .NET offers several methods to split PDF documents.

// Copy specified pages to a specified file
// Copy specified pages and automatically name the output file
public void Split( 
   string pageRange
)
 
// Split the document by specified number of pages
public void Split( 
   int pages
)

public void ExtractPagesTo( 
   string path,
   string pageRange
)

In this code example, I try to split a 6-page PDF document in several ways.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gnostice.PDFOne;

namespace PDFOne_dotNET_Examples {
   class PDF_Merge {
      static void Main(string[] args) {
         PDFDocument doc = new PDFDocument("your-license-key");
            
         // Load a PDF document
         doc.Load(@"F:\My eBooks\airlinetrailbrochure.pdf");
            
         // Creates 2-4,6.pdf
         doc.Split("2-4,6");  

         // Creates 1-4.pdf and 5-6.pdf
         // doc.Split(4);

         // Creates even_page.pdf with pages 2, 4 and 6
         // doc.ExtractPagesTo("even_pages.pdf", "2,4,6");

         // Closes the PDF document
         doc.Close();
      }
   }
}

Here is the input document.

Original 6-page document

Here is the output of the first Split() method. The method uses the pagerange parameter to name the output file.

Output document with just the 4 pages

Here is the output of the second Split() method. The output files are name after their original first and last page numbers. Even though the last file has only 2 page, it will still be given the full benefit of the multiple!

Split by number of pages

The method ExtractPages simply names the output file with the name specified in the path parameter.

ExtractPages method allows you name the output file

---o0O0o---

Our .NET Developer Tools
Gnostice Document Studio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
Gnostice Document Studio Java

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2023 Gnostice Information Technologies Private Limited. All rights reserved.