Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Task: Can anyone help me write a code for reading fields from a pdf file?  RSS feed

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a task, where I need to read numbers from a pdf file on  regular basis, anyone who has a idea about how to proceed for this ...?
 
Saloon Keeper
Posts: 4413
108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's hard. PDFs aren't meant for extracting particular pieces of text. You can try the PDFTextStripperByArea and PDFTextStripper classes that come with Apache PDFBox.

An example of the former is at https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/ExtractTextByArea.java?view=markup while the latter is shown in action at https://svn.apache.org/viewvc/pdfbox/trunk/tools/src/main/java/org/apache/pdfbox/tools/ExtractText.java?view=markup
 
VarunS Singh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I have to add additional jar for the above mentioned program?
 
Tim Moores
Saloon Keeper
Posts: 4413
108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just PDFBox. The pdfbox-app-2.0.8.jar file (available on the download page) has everything you need.
 
VarunS Singh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks..I am going to try that first.......but one question. What about if I need to extract some fields to an excel sheet? is that possible?
 
Sheriff
Posts: 23499
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. Get the data from the PDF and assign it to some variables, or data structure, in your code. Then write that data out to your spreadsheet.
 
Tim Moores
Saloon Keeper
Posts: 4413
108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and the best Java library for working with Excel files is Apache POI.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!