Skip to main content

Split PDF in Java

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​

  1. Create a PdfDocument object by passing the file path to the source PDF.
  2. Create a MergeDocument object by passing the pdf, starting page and page count.
  3. Invoke the Draw method on the Document to output that portion of the PDF.
  4. 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.