Reputation: 751
I found this article to be helpful but I need to expand on it a little to get what I need - Search Particular Word in PDF using Itextsharp
I have some text in my PDF that is like this:
Full Name: Bob Smith
The text "Full Name" will always be in the PDF but I don't know what the value of "Full Name" is and I need to be able to find that.
Is there a way to search a PDF for a certain text and get the value of the field instead of just looking for the field name? I need to be able to get "Bob Smith" or whatever is in that field. The name "Bob Smith" is going to be in the same place on each PDF and starts at the same number of spaces after the "Full Name" field, I am just not sure how to capture "Bob Smith"
Upvotes: 0
Views: 331
Reputation: 317
I am using ABCPDf but the logic might be same
get the whole document into a string by using some thing like GETTEXT
for (int i = 0; i <= doc.PageCount; i++)
{
doc.PageNumber = i;
theDocString += doc.GetText(Page.TextType.Text);
}
then search for certain string using Indexof
int index = theDocString.IndexOf(str, 0, StringComparison.CurrentCultureIgnoreCase);
bool isFound = index != -1;
Upvotes: 2