Hello,
I have got trouble deleting text from pdf document.
This is problematic file: Plik.pdf (824.4 KB)
This file contain dwo annotations. When I deleted annotation text (and annotation), the remaining text in line has shifted. (TextReplaceOptions.ReplaceAdjustment = NONE).
This is sample code how I deleting text:
// textFragmentsAsRectangles from annotation for (int i = textFragmentsAsRectangles.Count - 1; i >= 0; i--) { var rectangle = textFragmentsAsRectangles[i]; TextSearchOptions textOptions = new TextSearchOptions(rectangle, false); TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(phrase: null, textOptions); textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.None; try { page.Accept(textFragmentAbsorber); } catch { continue; } foreach (var textFragment in textFragmentAbsorber.TextFragments) { // The property (textFragment.Text) contains good text (highlighted in document) textFragment.Text = string.Empty; }
Summary: in sample document “TextReplaceOptions.ReplaceAdjustment.None” option not working for all text in document (There are place where this option works well).