In some cases,“textFragment.Rectangle” does not seem to reflect the real position,resulting big offset. The attached file is the case.
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(“经济”);
textFragmentAbsorber.TextSearchOptions.IsRegularExpressionUsed = true;
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
Aspose.Pdf.Rectangle myrectange;
myrectange = textFragment.Rectangle;
RedactionAnnotation ra = new RedactionAnnotation(textFragment.Page, myrectange);
textFragment.Page.Annotations.Add(ra);
ra.FillColor = textFragment.Page.Background;
ra.Color = textFragment.Page.Background;
result.jpg (153.6 KB)
input.pdf (721.6 KB)