PDFBox Adding Page - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
PDFBox Adding Page

PDFBox Adding Page

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-


  1. import java.io.IOException;   
  2. import org.apache.pdfbox.pdmodel.PDDocument;  
  3. import org.apache.pdfbox.pdmodel.PDPage;  
  4.   
  5. public class Main {  
  6.   
  7.     public static void main(String[] args)throws IOException {  
  8.         //Creating PDF document object   
  9.           PDDocument doc = new PDDocument();      
  10.       
  11.     for (inti=0; i<5; i++) {  
  12.     //Creating a blank page   
  13.               PDPage blankPage = new PDPage();  
  14.   
  15.     //Adding the blank page to the document  
  16.     doc.addPage( blankPage );  
  17.            }   
  18.       
  19.     //Saving the document  
  20.     doc.save("/eclipse-workspace/blank.pdf");  
  21.           
  22.           System.out.println("PDF created");    
  23.       
  24.     //Closing the document    
  25.     doc.close();  
  26.     }  
  27. }  

About Mariano

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.