Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Transparent text in existing PDFs

$
0
0
Hello,

I am trying to remove text from an existing PDF, whilst maintaining the positioning of the surrounding text. Because of this, simply setting textFragment.Text = "" is not a viable solution. I have tried a couple of things: replacing the text with a set number of spaces gave varying degrees of success - depending on exactly what text was surrounding the fragment - and setting the text fragment colour to Color.Transparent, which instead sets the text colour to white.

The code I am currently using is as follows:

Document document = new Document(path-to-file);

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(regularExpression);
textFragmentAbsorber.TextSearchOptions = new TextSearchOptions(true);
document.Pages.Accept(textFragmentAbsorber);

foreach (TextFragment tf in textFragmentAbsorber.TextFragments) {
tf.TextState.ForegroundColor = Color.Transparent;
}

document.Save(path-to-new-file);

Is what I am trying to accomplish not actually possible, or is there something I am missing?

Thank-you.

Viewing all articles
Browse latest Browse all 3131

Trending Articles