Hello,
nicolas.allerhand:I’m trying to find and highlight words in a pdf document.All is ok but when I want to use it for scanned document, the words are highlight but the text is no visible, it is under the yellow highlighted area…Hi Nicolas,Thanks for contacting support.I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-39278. We
will investigate this issue in details and will keep you updated on the status
of a correction. <o:p></o:p>
We apologize for your inconvenience.
In order to select text both in Upper case and Lower case, please try using Regular expression.nicolas.allerhand:Another question, When I'm searching for the word "win", It highlight some end of words like "growing" and it doesn't takes the word "Win" with the uppercase. Is this normal ?TextFragmentAbsorber absorber = new TextFragmentAbsorber("(?i)Win", new TextSearchOptions(true));
Hi Nayyer,
Hi Nicolas,
Document document = new Document(myDir
- “20072015045240._1.pdf”);<o:p></o:p>
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("(?i)Win");
//set text search option to specify regular expression usage
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
document.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection1 = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection1)
{
Aspose.Pdf.InteractiveFeatures.Annotations.HighlightAnnotation freeText = new Aspose.Pdf.InteractiveFeatures.Annotations.HighlightAnnotation(textFragment.Page, new Aspose.Pdf.Rectangle((float)textFragment.Position.XIndent,
(float)textFragment.Position.YIndent, (float)textFragment.Position.XIndent + (float)textFragment.Rectangle.Width,
(float)textFragment.Position.YIndent + (float)textFragment.Rectangle.Height));
freeText.Opacity = 0.5;
freeText.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Yellow);
textFragment.Page.Annotations.Add(freeText);
}
document.Save(myDir + "texthighlight_output.pdf");
Thanks a lot, this resolved all my problems.
Hi Nicolas,