Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read pdf file through java API

 
Jabi Vulla
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one tell me how to read pdf file through java API

I used all jars like pdfbox.jar... but bo use , can any one explain me with code???
BufferedReader br = new BufferedReader(new FileReader("//Summary_RPT_PDF//"+reportname+".pdf"));
if (br.readLine()== null ) {
......
else{
....
}
it showing exception like ...The network path was not found along with file not found exception.
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jabi Vulla wrote:"//Summary_RPT_PDF//"+reportname+".pdf"))

it showing exception like ...The network path was not found along with file not found exception.

That would suggest that the file either doesn't exist or is not accessible from the program. Does it exist - the two sets of // in the name look suspicious.
 
Tushar Arsekar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jabi Vulla wrote:Can any one tell me how to read pdf file through java API

I used all jars like pdfbox.jar... but bo use , can any one explain me with code???
BufferedReader br = new BufferedReader(new FileReader("//Summary_RPT_PDF//"+reportname+".pdf"));
if (br.readLine()== null ) {
......
else{
....
}
it showing exception like ...The network path was not found along with file not found exception.


If your file is on the shared network then access it using "\\hostname" + "\\Summary_RPT_PDF\\" + reportname + ".pdf"

If it is on your local drive then access it using "c:\\Summary_RPT_PDF\\" + reportname + ".pdf"
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For starters, PDF files contain binary data, not character data. That means any attempts to deal with them using Readers and Writers won't work - you need to use InputStreams and OutputStreams. Using those it is no problem to read and writ PDF files. But since you mention PDFBox, I'm guessing you want to achieve more than just get at the bytes that make up the file. If you told us what the underlying problem is, maybe we can point you to a more specific direction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic