Splitting PDF Documents
Splitting a PDF into multiple PDFs using DynamicPDF Core Suite for .NET is straightforward. The following example illustrates.
Watch the Video
How to Split PDF
The following steps and C# sample code illustrate splitting a PDF into multiple PDFs using DynamicPDF Core Suite for .NET.
Steps to Split a PDF
- Create a
PdfDocument
object and pass the source PDF file path to the constructor. - Create a
MergeDocument
object and in the constructor pass thePdfDocument
object instance, the starting page number, and ending page count. - Invoke the
Document
object'sDraw
method to output the PDF portion specified by the starting page number and ending page count. - Repeat step 2 and 3, only pass 5, and 9 to the
MergeDocument
constructor. - Invoke the
Draw
method, and a new PDF starting at page 5 and ending at page 12 is output to a new PDF document.
Sample Code - C#
PdfDocument pdf = new PdfDocument("TimeMachine.pdf");
MergeDocument part1 = new MergeDocument(pdf, 1, 4);
Part1.Draw("output-part1.pdf");
MergeDocument part2 = new MergeDocument(pdf, 5, 8);
part2.Draw("output-part2.pdf");
GitHub Project
An example project is available on GitHub (examples.dynamicpdf-core-suite-dotnet-core). Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This specific example discussed on this page are all contained in following classes on GitHub
- C# - SplitPdfExample.cs
- VB.NET - SplitPdfExample.vb
Getting Started
Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing the product.
NuGet Package
The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.
DynamicPDF Core Suite Information
DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!
More Information on Merging
- Refer to the Merging Overview documentation topic, or
- Chapter 22, Merging, in the book DynamicPDF Core Suite for .NET by Example available on GitHub.
Available on Other Platforms
DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.
- DynamicPDF Generator
- Java - DynamicPDF Generator for Java
- COM/ActiveX - DynamicPDF Generator for COM/ActiveX
- DynamicPDF Merger
- Java - DynamicPDF Merger for Java
- COM/ActiveX - DynamicPDF Merger for COM/ActiveX