I’m trying to change the color of some text in PDF files but for some reason this does not work the way I hoped. If I change the background color everything comes out correct
textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Yellow);
But if I try changing the foreground color much of the surrounding text disappears.
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
The text seems to still be there as I can select it but it might be set to white as the background. This is the code I’m using
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("number");
TextSearchOptions textSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextSearchOptions = textSearchOptions;
for (int i = 1; i < 3; i++)
{
editor.Document.Pages[i].Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
}
}
Can anyone see what I’m doing wrong?