RedactionAnnotation captures adjacent letters.
How can this be solved?
Listing of our replacement program:
Document pdf = new Document(dataDir + "inputPDF.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("uu");
textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.None;
pdf.Pages.Accept(textFragmentAbsorber);
TextFragment textFragment = textFragmentAbsorber.TextFragments[1];
RedactionAnnotation ra = new RedactionAnnotation(textFragment.Page, textFragment.Rectangle);
textFragment.Page.Annotations.Add(ra);
ra.Redact();
textFragment = textFragmentAbsorber.TextFragments[2];
char space = ' ';
double rectangleWeight = textFragment.Rectangle.Width;
textFragment.Text = space.ToString();
textFragment.Text = new string(space, (int)(rectangleWeight / textFragment.Rectangle.Width) + 1);
textFragment.TextState.BackgroundColor = Color.Black;
pdf.Save(dataDir + "redacted.pdf");
Source file in the attachment. Also in the attachment is obtained and the desired result.
inputPDF.pdf (12.9 KB)