Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
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.
Here is the output of the first Split()
method. The method uses the
pagerange
parameter to name the output file.
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!
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 .NETMulti-format document-processing component suite for .NET developers. |
![]() PDFOne .NETA .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 DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
![]() eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
![]() PDFtoolkit VCLA 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 JavaMulti-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 | |
---|---|
![]() StarDocsCloud-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. |