如何在现有PDF中使用iTextSharp向其他页面插入超链接?

我想添加一个链接到现有的pdf,跳转到另一个页面上的坐标。

我可以使用以下代码添加一个矩形:

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(); 

我怎样才能创建一个可点击的链接呢? 谢谢。

这在“iText in Action – Second Edition”一书的第7章中有解释。 您可以在此处找到示例: http : //itextpdf.com/examples/iia.php?id = 150

如果你需要C#版本,请看这里: http : //kuujinbo.info/iTextInAction2Ed/index.aspx

更具体地说: http : //kuujinbo.info/iTextInAction2Ed/index.aspx?ch=Chapter07&ex=TimetableAnnotations2

 PdfAnnotation annotation = PdfAnnotation.CreateLink( stamper.Writer, rect, PdfAnnotation.HIGHLIGHT_INVERT, new PdfAction("http://itextpdf.com/") ); stamper.AddAnnotation(annotation, page); 

在此代码中,示例page是要添加链接的页面编号, rect是定义该页面上坐标的Rectangle对象。