Underline after changing the text color

I am using Aspose PDF library for .Net version 24.10 in my application,
For one of the PDF file(attached file “sample-error-3.pdf”) , I am facing an issue,
when I create link for the text “Section 2.1” or for the text “Section 3.3”, and apply color change for the text,
after creating and applying change, it is placing underline for those text items, even thoough I have not set the underline property for the text.
When I do the same using Adobe library Plug-in application, it is working fine, seems it is an issue with Aspose PDF library.

//********Code we using for the same
static void Main(string[] args)
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.Embedded = true;

        //place this project folder under 'C' drive,
        //else if placing in other drive, update the drive letter in below 2 lines.
        license.SetLicense("C:\\SampleProject\\SampleProject\\Aspose.Pdf.lic");

        string sfilepath = "C:\\SampleProject\\SampleProject\\sample-error-3.pdf";
        Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(sfilepath);


        Aspose.Pdf.Page page = pdfDoc.Pages[1];
        Aspose.Pdf.Rectangle AnnotRect = new Aspose.Pdf.Rectangle(229.9590, 704.8103, 276.7716, 725.4373);
        LinkAnnotation link = new LinkAnnotation(page, AnnotRect);
        Border border = new Border(link);
        TextFragmentAbsorber absorber = new TextFragmentAbsorber();
        absorber.TextSearchOptions.Rectangle = AnnotRect;
        page.Accept(absorber);

        foreach (TextFragment textFragment in absorber.TextFragments)
        {
            textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(0, 0, 0);

        }
        border.Width = 0;
        link.Border = border;
        page.Annotations.Add(link);
        pdfDoc.IsLinearized = true;
        pdfDoc.Save(sfilepath);

    }

//***********************************End of code ***********************

	   I have attached sample files, sample-error-3.pdf which is before applying change.
       also After_Creating_Links_sample-error-3.pdf which is after applying change for your reference,

Please verify this bug and provide the suitable resolution.
After_Creating Links_sample-error-3.pdf (70.0 KB)

sample-error-3.pdf (73.3 KB)

@IqviaPal

It seems you are experiencing an issue with the Aspose PDF library where applying a color change to text links results in an unintended underline appearing on the text. This behavior is not present when using other PDF libraries, such as Adobe’s.

To address this issue, you can try the following approach, which is similar to the code you provided but includes a check to ensure that the underline property is not set inadvertently. Here’s a modified version of your code:

static void Main(string[] args)
{
    Aspose.Pdf.License license = new Aspose.Pdf.License();
    license.Embedded = true;
    license.SetLicense("C:\\SampleProject\\SampleProject\\Aspose.Pdf.lic");

    string sfilepath = "C:\\SampleProject\\SampleProject\\sample-error-3.pdf";
    Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(sfilepath);

    Aspose.Pdf.Page page = pdfDoc.Pages[1];
    Aspose.Pdf.Rectangle AnnotRect = new Aspose.Pdf.Rectangle(229.9590, 704.8103, 276.7716, 725.4373);
    LinkAnnotation link = new LinkAnnotation(page, AnnotRect);
    Border border = new Border(link);
    TextFragmentAbsorber absorber = new TextFragmentAbsorber();
    absorber.TextSearchOptions.Rectangle = AnnotRect;
    page.Accept(absorber);

    foreach (TextFragment textFragment in absorber.TextFragments)
    {
        textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(0, 0, 0);
        // Ensure underline is not set
        textFragment.TextState.Underline = false; // Add this line to prevent underlining
    }
    
    border.Width = 0;
    link.Border = border;
    page.Annotations.Add(link);
    pdfDoc.IsLinearized = true;
    pdfDoc.Save(sfilepath);
}

In this modified code, I added a line to explicitly set the Underline property of the TextState to false. This should help prevent the underline from appearing when you change the text color.

If the issue persists, it may be beneficial to check for any other properties or settings that could be affecting the text appearance. Additionally, consider reaching out to Aspose support with your specific PDF files for further assistance, as they may be able to provide more targeted help based on the files you are working with.

If you have any further questions or need additional assistance, feel free to ask!

I tried adding the line
textFragment.TextState.Underline = false;
even after that, the underline issue is replicated. I have attached the file, which is processed after adding the above line of code. Please help me to resolve this issue
sample-error-3.pdf (70.0 KB)

@IqviaPal
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-59760

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Any updates on this issue?

@IqviaPal
Unfortunately, there is nothing new on this task so far.