Change text color of Link Annotation

Hi Chenna,

Thanks for your inquiry. Yes, we have improved text searching procedure in PDFNET-41381 fix, and now TextFragmentAbsorber returns text under rectangle more accurate. The rectangle may be specified with TextFragmentAbsorber.TextSearchOptions.Rectangle property.

However to change color of individual characters is more complicated task, so we have created a separate issue PDFNET-41556 for it. I am afraid it is still not resolved and we will let you know as soon as some update is available.

Aspose.Pdf.Rectangle rect = new Aspose.Pdf.Rectangle(110, 710, 310, 760);

Document doc = new Document("sample.pdf");
Page page = doc.Pages[1];

Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation annot =
    new Aspose.Pdf.InteractiveFeatures.Annotations.LinkAnnotation(page, rect);

annot.Highlighting = Aspose.Pdf.InteractiveFeatures.HighlightingMode.Outline;
page.Annotations.Add(annot);

TextFragmentAbsorber absorber = new TextFragmentAbsorber();
absorber.TextSearchOptions.Rectangle = rect;

page.Accept(absorber);

foreach (TextFragment textFragment in absorber.TextFragments)
{
    textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
}

doc.Save("sample_out.pdf");

Best Regards,

Hi,

Still this did not resolve the issue, if you want to check this please verify with the document “Link-Color-Issue-Input.pdf” which is already attached with this chain. Please verify for all links and you will come to know for which link it is applying color properly and for which it is not.

Thanks & Regards

Chenna Basappa C

Hi Chenna,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 16.10.0 and as per my observations, the link color is not being updated. For your reference, I have attached the output generated over my end.

Can you please confirm if you are facing similar issue or you have some different observations.

[C#]

Aspose.Pdf.Rectangle rect = new Aspose.Pdf.Rectangle(110, 710, 310, 760);

Document doc = new Document("c:/pdftest/Link-Color-Issue-Input.pdf");
Page page = doc.Pages[1];

Aspose.Pdf.Annotations.LinkAnnotation annot = 
    new Aspose.Pdf.Annotations.LinkAnnotation(page, rect);

annot.Highlighting = Aspose.Pdf.Annotations.HighlightingMode.Outline;
page.Annotations.Add(annot);

TextFragmentAbsorber absorber = new TextFragmentAbsorber();
absorber.TextSearchOptions.Rectangle = rect;

page.Accept(absorber);

foreach (TextFragment textFragment in absorber.TextFragments)
{
    textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.Blue;
}

doc.Save("c:/pdftest/Updated_Link-Color-Issue-Input.pdf");

Hi Nayyer Shahbaz,

I am not referring to link rectangle color, I think you misunderstood the issue.
I am trying to change the color of text with-in link rectangle.
If you take the same document you have attached “Updated_Link-Color-Issue-Input.pdf”, I wanted to change the color of the text to blue with-in link rectangle.
When I tried text color is changed to blue for some links but for some links the color of the text did not change properly. I have explained this in my earlier threads with sample files.

Let me know if you need any more information on this.

Thanks,

Chenna Basappa

Hi Chenna,


We are sorry for the confusion. Please note we have already stated that we have enhanced text searching logic in PDFNET-41381 fix it did not fix the text color change issue. We have logged another ticket PDFNET-41556 for it and we will notify you as soon as it is resolved.

Thanks for your patience and cooperation.

Best Regards,