I would like to add a link to an existing pdf that jumps to a coordinate on another page.
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; overContent.Rectangle(rectangle); stamper.Close();
How can I do similar to create a link that is clickable?
You are already adding the
Rectangle, now you need to add the annotation:
PdfAnnotation annotation = PdfAnnotation.CreateLink( stamper.Writer, rectangle, PdfAnnotation.HIGHLIGHT_INVERT, new PdfAction("https://itextpdf.com/") ); stamper.AddAnnotation(annotation, page);
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.
Click this link if you want to see how to answer this question in iText 7.