We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

TextState.ForegroundColor not working

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?

Hi Geir,


Thanks for using our products.

I have tested the scenario using one of my sample PDF files and I am unable to notice any issue. The problems seems to be related to the source PDF file which you are using. can you please share the source PDF document so that we can test the scenario at our end. We are sorry for this inconvenience.

Hi

Here is a testfile and some images of the results.

Hi Geir,


Thanks for sharing the resource files.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this issue
as PDFNEWNET-35239 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

The issues you have found earlier (filed as PDFNEWNET-35239) have been fixed in Aspose.Pdf for .NET 9.4.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.