Javatpoint Logo
Javatpoint Logo

PDFBox Splitting PDF Document

We can split the given PDF document into multiple PDF files. The Splitter class can split each PDF file into an individual file. This class is used to split the given PDF document into several other separate documents.

To split an existing PDF file, do the following-

Load Existing Document

We can load the existing PDF document by using the static load() method. This method accepts a file object as a parameter. We can also invoke it using the class name PDDocument of the PDFBox.

Create Splitter Object

The splitter class is used to split the existing PDF document. We can instantiate the splitter class as following.

Split PDF Document

We can split the existing PDF document by using the split() method of the splitter class. split() method accepts an object of PDDocument class as a parameter.

Create Iterator Object

The listIterator() method can be used to get the iterator object. This iterator object used to traverse the list of documents we need. The following code create iterator object.

Close Document

After completing the task, we need to close the PDDocument class object by using the close() method.


It is a PDF document which contains five pages. The first two pages contains images. We are going to split both pages, which contains images as individual file through a Java Program.

PDFBox Splitting PDF Document

Java Program


After successful execution of the above program, we can see the following output.

PDFBox Splitting PDF Document

Now for verification, open the PDF files individually, which can be shown below-

PDFBox Splitting PDF Document
PDFBox Splitting PDF Document

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA