Javatpoint Logo
Javatpoint Logo

PDFBox Adding Page

To add page in PDF document two things must be needed-

PDFBox Adding Page

Follow the steps below to add pages in PDF document-

Create 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.

Add Page

addPage () method is used to add pages in the PDF document. The following code add page in our PDF document.

Save 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.

Close Document

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.

PDFBox Adding Page

Now, we can see the blank page in the PDF document which is shown in the following screenshot.

PDFBox Adding Page

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA