Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am getting problem to read pdf files using iText in java. I can read only one page but when I go to second page it gives exception.I want to read all the pages of any pdf file.

PdfTextExtractor parser =new PdfTextExtractor(new PdfReader("C:/Text.pdf"));
parser.getTextFromPage(3);

I am using these lines and at second line gives exception.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
208 views
Welcome To Ask or Share your Answers For Others

1 Answer

  1. Try changing the file location. Sometimes OS does not allow file to be read from some system drives by other applications. Put somewhere in D: etc. I face this problem in Vista when reading files from desktop.

  2. I in fact ran the same two lines of code on one of my PDF and it did print the text. Also make sure you have sufficient pages in the PDF. (3 pages or more) or try with parser.getTextFromPage(1) etc. to get content from other pages.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...