How can I change the color for text covered with link annotation?


I would like to change link text color.
Using the following code I am able to extract Link text color

ElementReader reader=new ElementReader();
Element element;

while((element = reader.Next()) != null) {
  Rect bbox = new Rect();
  if(bbox.IntersectRect(bbox,annot.GetRect())) {
    GState gs=element.GetGState();
    ColorPt textColor = gs.GetFillColor();
    ColorSpace tcs = gs.GetFillColorSpace();

    ColorPt textRGB = new ColorPt();
    tcs.Convert2RGB(textColor, textRGB);

    int tr=(int)(textRGB.Get(0)*255);
    int tg=(int)(textRGB.Get(1)*255);
    int tb=(int)(textRGB.Get(2)*255);


Now, how can I change the color for text covered with link
annotation ?


Modifying the color of text under that link is not as trivial as
modifying certain properties in the annotation object. Instead you
would need to edit the page content by changing the text color on all
text elements covered with link annotation. As a starting point you
may want to take a look at ElementEdit sample project (http:// In this sample, the
text color is changed from black to blue (for all text on the page).
The code can be extended to modify text color only if the bounding box
of a text run (element.GetBox()) occurs within the area covered by the
link annotation (annot.GetRect()). Things may become more complicated
if you need to change color only on parts of a word/text string. In
this case you would need to break the text run into one or more text
runs (using ElementBuilder) and then write new elements instead of the
old element.