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

Free Support Forum - aspose.com

Unable to change linkannotation text color in pdf

Unable to change linkannotation text color in pdf.

Hi Srini,


Thanks for contacting support.

We are working over this query and will get back to you soon.

Hi Srini,


Thanks for your patience.

The Link annotation does not contain text. Text is placed in the contents of the page under the annotation.
Therefore in order to change color of the text, we need to replace color of the page text instead of trying change color of the annotation.

This may be done in the following way:

[C#]

Document doc = new Document(“AsposeCaseExample.pdf”);<o:p></o:p>

foreach (Annotation annotation in doc.Pages[1].Annotations)

{

if (annotation is LinkAnnotation)

{

//search text under the annotation

TextFragmentAbsorber ta = new TextFragmentAbsorber();

Rectangle rect = annotation.Rect;

rect.LLX -= 10;

rect.LLY -= 10;

rect.URX += 10;

rect.URY += 10;

ta.TextSearchOptions = new TextSearchOptions(rect);

ta.Visit(doc.Pages[1]);

//change color of the text.

foreach (TextFragment tf in ta.TextFragments)

{

tf.TextState.ForegroundColor = Color.Red;

}

}

}

doc.Save("output.pdf");