Bax*_*ter 6 pdf anchor cell hyperlink itextsharp
我能够成功地在pdf中添加友好名称的链接:
Anchor anchor = new Anchor("Google", linkFont);
anchor.Reference = "https://www.google.com";
doc.Add(anchor);
Run Code Online (Sandbox Code Playgroud)
但是,我无法让锚在PdfPCell中工作.
这是我到目前为止所尝试的:
var memberCell = new PdfPCell();
Anchor anchor = new Anchor("Google", linkFont);
anchor.Reference = "https://www.google.com";
memberCell.AddElement(new Anchor(anchor));
Run Code Online (Sandbox Code Playgroud)
这显示异常:System.ArgumentException:不允许元素.
我也尝试过:
var memberCell = new PdfPCell();
Anchor anchor = new Anchor("Google", linkFont);
anchor.Reference = "https://www.google.com";
memberCell.AddElement(new Phrase(anchor));
Run Code Online (Sandbox Code Playgroud)
这不会引发异常,但它不是一个链接,它只是单词"Google".
我正在使用最新版本的iTextSharp v.(5.4.4.0)
任何有关这方面的帮助将不胜感激.
Chr*_*aas 16
而不是Anchor
使用a Chunk
并调用SetAnchor()
方法:
var c = new Chunk("Google");
c.SetAnchor("https://www.google.com");
memberCell.AddElement(c);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6730 次 |
最近记录: |