PDFBox Adding PageTo add page in PDF document two things must be needed- ![]() Follow the steps below to add pages in PDF document- Create DocumentCreate an instance of PDDocument class which belongs to the package org.apache.pdfbox.pdmodel. Getting an instance of PDDocument class, we are able to create an empty PDF document. Create Blank PageThe PDPage class is used to create a blank page in a PDF document. The following code create page in our PDF document. Add PageaddPage () method is used to add pages in the PDF document. The following code add page in our PDF document. Save DocumentAfter creating document, we have to save the document 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, we will see the following output message. ![]() Now, we can see the blank page in the PDF document which is shown in the following screenshot. ![]()
Next TopicPDFBox Load Existing Document
|