我想添加一个链接到现有的PDF跳转到其他网页上的坐标。
I would like to add a link to an existing pdf that jumps to a coordinate on another page.
我可以用这个code添加一个矩形:
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? Thanks.
这是在书中的第7章解释的iText在行动 - 第二版。你可以找到一个例子在这里: http://itextpdf.com/examples/iia.php? ID = 150
This is explained in chapter 7 of the book "iText in Action - Second Edition". You can find an example here: http://itextpdf.com/examples/iia.php?id=150
如果你需要的C#版本,请看看这里: http://kuujinbo.info/iTextInAction2Ed /index.aspx
If you need the C# version, please take a look here: 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);
在此code样品页
是要在其中添加链接,矩形是
矩形
确定该网页上的坐标对象。
In this code sample page
is the number of the page where you want to add the link and rect
is the Rectangle
object defining the coordinates on that page.