One of our client has proposed the use of Aspose libraries for extracting important information from .Doc or .pdf files. Currently I am looking at .doc file but I find the documention/examples are more for creating/writing to a word file.
Do you have sample code for
- reading a doc file,
- searching for certain keywords/text in doc file
say search for keyword Opinion and get value ‘Good’
eg … Opinion : Good
another eg … Rating : 6
search for key word Rating and get value 6
Regards
Ganesh
This message was posted using Page2Forum from Programmer’s Guide - Aspose.Words for .NET and Java
Hi
Thanks for your inquiry. I think, you can try using ReplaceEvaluator to get such data from your document. For example, see the following example:
// Open document.
Document doc = new Document(@"Test001\in.doc");
// Create regular expression, which will help us to get data from the document.
Regex regex = new Regex(@"(?\S+)\s*:\s*(?\S+)");
// We will use ReplaceEvaluator to get data.
doc.Range.Replace(regex, new ReplaceEvaluator(ReplaceEvaluatorGetData), true);
private static ReplaceAction ReplaceEvaluatorGetData(object sender, ReplaceEvaluatorArgs e)
{
// Print name / value pair, which was matched by our regex.
Console.WriteLine("{0} = {1}", e.Match.Groups["name"], e.Match.Groups["value"]);
return ReplaceAction.Skip;
}
Hope this helps. Please let me know in case of any issues, I will be glad to help you.
Best regards.