PDFBox Load Existing DocumentThis 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 DocumentWe 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 OperationsAfter loading the existing PDF document, we can perform the operations on it like adding text, removing text, adding an image, removing page etc. Save DocumentAfter 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 DocumentAfter 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. ![]()
Next TopicPDFBox Adding Text
|