Splitting a PDF with DynamicPDF Merger is a simple and straightforward task. Below are the steps and sample code for this.
Steps to Split a PDF
- Create a
PdfDocumentobject by passing the file path to the source PDF.
- Create a
MergeDocumentobject by passing the pdf, starting page and page count.
- Invoke the
Drawmethod on the Document to output that portion of the PDF.
- Repeat step 2 and 3 for the remaining parts of the PDF you'd like to split.
Sample code - C#
PdfDocument pdf = new PdfDocument("DocumentA.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");
DynamicPDF Generator is available on NuGet and is part of the
package. The Core Suite package includes Generator, Merger and ReportWriter.
GitHub Example Project
Clone or view the example project at GitHub. This example is is the Examples/SplitPDF.cs file.
DynamicPDF Merger Information
More information can be found here:
DynamicPDF Merger PDF Library is available for Java and COM/AxtiveX platforms. Refer to the respective product pages for more details.