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.
Asked
Active
Viewed 1.9k times
-1
-
This is something you need to write in a search engine, not here. – npinti Sep 17 '15 at 10:49
-
No !I do not find answer as my requirement. I get the answer in c++. – pampa Sep 17 '15 at 10:58
-
I do not also found how to write the line in txt file. I have solve the problem ,but can not read or write the data line by line – pampa Sep 17 '15 at 11:02
1 Answers
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