Javatpoint Logo
Javatpoint Logo

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.

Perform Operations

After loading the existing PDF document, we can perform the operations on it like adding text, removing text, adding an image, removing page etc.

Save Document

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.

Close Document

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

Example-

Output:

After successful execution of the above program, it will display the following message.


PDFBox Load Existing Document
Next TopicPDFBox Adding Text





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA