PDFBox Adding Page
To add page in PDF document two things must be needed-
Follow the steps below to add pages in PDF document-
- import java.io.IOException;
- import org.apache.pdfbox.pdmodel.PDDocument;
- import org.apache.pdfbox.pdmodel.PDPage;
- public class Main {
- public static void main(String[] args)throws IOException {
- //Creating PDF document object
- PDDocument doc = new PDDocument();
- for (inti=0; i<5; i++) {
- //Creating a blank page
- PDPage blankPage = new PDPage();
- //Adding the blank page to the document
- doc.addPage( blankPage );
- }
- //Saving the document
- doc.save("/eclipse-workspace/blank.pdf");
- System.out.println("PDF created");
- //Closing the document
- doc.close();
- }
- }
0 comments:
Post a Comment