Hi guys,
I need help using a regex to search on a pdf file. A call to pdfDocument.Pages.Accept(textFragmentAbsorber); does not return until it gets outofmemory exception. I have .* for my regex to query all the contents of a text file converted to pdf. I have attached the source pdf.
Please help me understand what’s wrong with my code. I appreciate you all!!!
private void btnSearch_Click(object sender, EventArgs e)
{
Document pdfDocument = new Document(txtSource.Text);
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(".*", textSearchOptions);
//This call to "Accept" is not returning until it would get an outofmemory exception.
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = "<MODIFIEDTEXT>";
textFragment.TextState.Font = FontRepository.FindFont("Verdana");
textFragment.TextState.FontSize = 22;
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.Green;
}
pdfDocument.Save(txtDestination.Text);
}
texttopdf.pdf (47.8 KB)
-Nell