How to highlight a Anchor Name attribute text

83 views Asked by At

I am creating a PDF using iTextsharp. In that I have created internal links with Anchor and its working perfectly. Here is my code.

Anchor click = new Anchor("Go to Target");
click.Reference = "#target";
Paragraph p1 = new Paragraph();
p1.Add(click);
doc.Add(p1);

iTextSharp.text.Font contentFont = new iTextSharp.text.Font(BaseFont.CreateFont(@"C:\Windows\Fonts\arialbd.ttf", BaseFont.CP1252, false), 4.5f);
p1.Font = contentFont;

doc.NewPage();

Anchor target = new Anchor("This is the Target");
target.Name = "target";
Paragraph p3 = new Paragraph();
p3.SpacingBefore = 100;
p3.Add(target);
doc.Add(p3);

when I click on "Go to Target" text, the PDF will immediately reposition itself to "This is the Target" text and I want to change color or highlight of a "This is the Target" text when click event occurs.

0

There are 0 answers