read pdf java

Solutions on MaxInterview for read pdf java by the best coders in the world

showing results for - "read pdf java"
Casper
27 Jan 2017
1import java.io.File;
2import java.io.IOException;
3import org.apache.pdfbox.pdmodel.PDDocument;
4import org.apache.pdfbox.text.PDFTextStripper;
5public class PdfToConsole {
6   public static void main(String args[]) throws IOException {
7      //Loading an existing document
8      File file = new File("D://Sample.pdf");
9      PDDocument document = PDDocument.load(file);
10      //Instantiate PDFTextStripper class
11      PDFTextStripper pdfStripper = new PDFTextStripper();
12      //Retrieving text from PDF document
13      String text = pdfStripper.getText(document);
14      System.out.println(text);
15      //Closing the document
16      document.close();
17   }
18}