PDFBox Adding Page
To add page in PDF document two things must be needed-
Follow the steps below to add pages in PDF document-
Create 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 Page
The PDPage class is used to create a blank page in a PDF document. The following code create page in our PDF document.
addPage () method is used to add pages in the PDF document. The following code add page in our PDF document.
After 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.
After completing the task we need to close the PDDocument class object by using the close() method.
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