Q:
I want to find all the hyperlink annotations in a PDF, and make them have a blue underline.
A:
The following code will do this.
for (PageIterator itr = doc.GetPageIterator(); itr.HasNext(); itr.Next())
{
Page page = itr.Current();
int num_annots = page.GetNumAnnots();
for (int i=0; i<num_annots; ++i)
{
Annot annot = page.GetAnnot(i);
if (!annot.IsValid()) continue;
if(annot.GetType() == Annot::e_Link)
{
Annots::Link link(annot);
Action action = link.GetAction();
if (!action.IsValid()) continue;
if (action.GetType() == Action::e_URI)
{
link.SetBorderStyle(Annot::BorderStyle(Annot::BorderStyle::e_underline, 3));
link.SetColor(ColorPt(0, 0, 1));
link.RefreshAppearance();
}
}
}
}
To also change the text underneath the link annotation to the same color, see this post
https://groups.google.com/d/msg/pdfnet-sdk/dLcJ9aQm00g/VRFE6od1HrgJ