PDFBox Load Existing Document - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
PDFBox Load Existing Document

PDFBox Load Existing Document

PDFBox Load Existing Document

This section describes how to load PDF document that already exists in our system. By loading the existing document we can perform many operations on it like adding text, removing text, adding an image, removing page etc.

mport java.io.File;
import java.io.IOException;
 
import org.apache.pdfbox.pdmodel.PDDocument; 
import org.apache.pdfbox.pdmodel.PDPage;
public class LoadingExistingDocument {

   public static void main(String args[]) throws IOException {
   
      //Loading an existing document 
      File file = new File("C:/PdfBox_Examples/sample.pdf"); 
      PDDocument document = PDDocument.load(file); 
        
      System.out.println("PDF loaded"); 
        
      //Adding a blank page to the document 
      document.addPage(new PDPage());  

      //Saving the document 
      document.save("C:/PdfBox_Examples/sample.pdf");

      //Closing the document  
      document.close(); 
        
   }  
}

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.