How to insert a hyperlink to another page in an existing PDF?

I would like to add a link to an existing pdf that jumps to a coordinate on another page.

31st May 2016

I am able to add a rectangle using this code:


PdfContentByte overContent = stamper.GetOverContent(1);
iTextSharp.text.Rectangle rectangle = new Rectangle(10,10,100,100,0);
rectangle.BackgroundColor = BaseColor.BLUE;
How can I do similar to create a link that is clickable?


Posted on StackOverflow on Nov 19, 2012 by dazzler77

You are already adding the Rectangle, now you need to add the annotation. This is how it looks in Java:

PdfAnnotation annotation = new PdfLinkAnnotation(rectangle)
        .setBorder(new PdfArray(new int[] {0,0,1}));

In this code sample page is the number of the page where you want to add the link and rectangle is the Rectangle object defining the coordinates on that page. You can use the similar methods in iTextSharp.

Click this link if you want to see how to answer this question in iText 5.


Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now