Split PDF in Java
How to Split PDF pages
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
PdfDocument
object by passing the file path to the source PDF. - Create a
MergeDocument
object by passing the pdf, starting page and page count. - Invoke the
Draw
method 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 - Java
PdfDocument pdfToSplit = new PdfDocument("DocumentA.pdf");
MergeDocument part1 = new MergeDocument(pdfToSplit, 1, 4);
part1.draw("output-part1.pdf");
MergeDocument part2 = new MergeDocument(pdfToSplit, 5, 8);
part2.draw("output-part2.pdf");
Getting Started
DynamicPDF Merger Information
More information can be found here:
Available in Other Platforms
DynamicPDF Merger PDF Library is available for .NET and COM/AxtiveX platforms. Refer to the respective product pages for more details.
- .NET - DynamicPDF Merger for .NET
- COM/ActiveX - DynamicPDF Merger for COM/ActiveX