Hello,
I am trying to remove text from PDF files and when doing so there is some text that is moved from the original position.
Even with the TextReplaceOptions.ReplaceAdjustment.None in the TextFragmentAbsorber, it just behave like it is using the default option of adjust.
Bellow is the code that handles this, executed in an extension of OutSystems.
//find slanted text fragments according to imput angle
if ((ssangle > 180) || (ssangle < 0))
{
throw new System.ArgumentException("angle must be between 0 and 180", "original");
}
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.None;
document.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment tf in textFragmentCollection)
{
if (tf.TextState.Rotation >= ssangle || tf.TextState.Rotation <= -ssangle)
{
ssResultMessage = ssResultMessage + "Text: [" + tf.Text + "] Rotation: [" + tf.TextState.Rotation + "] ReplaceAdjustment: [" + textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction + "]";
tf.Text = "";
}
}
I cannot provide the PDF files for privacy reasons, but what happens is that when a diagonal text that starts at the left of a value is removed, moves the value to the left taking it out of position.
Before Text = “”:
Unallocated Capital Start of diagonal text Value1
After Text = “”:
Unallocated Capital Value1