-1

How to read pdf file line by line using java, And write the lines in .txt and .doc file? Please mention the required .jar for the program.

pampa
  • 153
  • 1
  • 3
  • 11

1 Answers1

6

Using PDFBox

try{
PDDocument document = null; 
document = PDDocument.load(new File("test.pdf"));
document.getClass();
if( !document.isEncrypted() ){
    PDFTextStripperByArea stripper = new PDFTextStripperByArea();
    stripper.setSortByPosition( true );
    PDFTextStripper Tstripper = new PDFTextStripper();
    String st = Tstripper.getText(document);
    System.out.println("Text:"+st);
}
}catch(Exception e){
    e.printStackTrace();
}

You can download it from here

Vivek Aditya
  • 1,145
  • 17
  • 46