PDFBox Load Existing Document
This section describes how to load PDF document that already exists in our system. By loading the existing document we can perform many operations on it like adding text, removing text, adding an image, removing page etc.
Follow the steps below to load the existing PDF document -
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.
After loading the existing PDF document, we can perform the operations on it like adding text, removing text, adding an image, removing page etc.
After adding the required document, we have to save it to our desired location. save() method is used to save the document. The save() method accepts a string value and passes a path of the document as a parameter.
After completing the task, we need to close the PDDocument class object by using the close() method.
After successful execution of the above program, it will display the following message.