Reputation: 8763
In .Net, what would be the best way to extract all the text out of several binary file formats: PDF, Word, Excel, and PowerPoint.
It doesn't need to be formatted, just a big dump of the text in the file.
Code would be great, but I really just need to get pointed to some best practices or patterns on it.
Upvotes: 1
Views: 2047
Reputation: 3347
Check out Apache Tika.
It supports:
Upvotes: 1
Reputation: 103760
I'm surprised no one has mentioned IFilters. IFilters is what Microsoft uses to index documents in windows. You'll have to do some googling to find IFilters for the specific formats you're looking for, but you should find most of what you need. A word of caution though, IFilters aren't perfect. They have issues.....
Here's a CodProject article to get you started: http://www.codeproject.com/KB/cs/IFilter.aspx
Upvotes: 3
Reputation: 86116
Look into Office Interop using .Net for the Office ones. For PDF, see here.
Upvotes: 0
Reputation: 792
You'd probably have to implement a different way to handle each file type. There is a lot of sample code around to read these formats, using office interop etc.. then you could write a method that looked at the first few bytes to work out what format the document is, or the extension and send it to the specific reader for that type of document.
Upvotes: 1
Reputation: 354734
Well, the same as in any other language/environment: Understand the file format enough to extract strings.
And yes, for many file formats this means that you should write at least half a parser for the format. PDF is especially icky, as there are no spaces per se; that's just a convention of how far apart the glyphs are; furthermore PDF can contain compressed streams so simply searching for printable strings in the file doesn't yield anything of value.
Naturally, you can look for a library or another tool which already does this. I've seen a document repository which simply passed PDF files through pdf2ascii and fed the resulting text to Lucene.
Upvotes: 1