首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我正尝试在pdf中插入指向另一个网站的超链接

我正尝试在pdf中插入指向另一个网站的超链接
EN

Stack Overflow用户
提问于 2019-07-26 16:15:48
回答 1查看 191关注 0票数 0

在FormField "HH“我试图使文本作为链接,但它只读为字符串文本,它是不可点击的。我使用Aspose.Pdf v.11.6.0。

代码语言:javascript
运行
复制
var doc = new Aspose.Pdf.Document(pdfFileStream);

var pdfForm = new Aspose.Pdf.Facades.Form(doc);
pdfForm.FillField("Name", model.Name.ToUpper());
pdfForm.FillField("ISOS", model.NumberISOS.ToUpper());
pdfForm.FillField("Info", dateInfo);

pdfForm.FillField("HH", "http://www.somewebsite.com");

我使用以下代码:

代码语言:javascript
运行
复制
 Page page = (Page)doc.Pages[1];
 var text = new TextFragment("index");
 text.Position = new Position(200, 300);
 Aspose.Pdf.WebHyperlink link = new 
 WebHyperlink("www.google.com");
 text.Hyperlink = link;
 page.Paragraphs.Add(text);

但新位置(200,300);值不响应。

EN

回答 1

Stack Overflow用户

发布于 2019-07-30 18:51:39

这是我的解决方案,因为位置不起作用,所以我移动带有边距的链接。这对我很有效。

代码语言:javascript
运行
复制
Page page = (Page)doc.Pages[1];
var text = new TextFragment("LINK");
text.Position = new Position(300, 300);
Aspose.Pdf.WebHyperlink link = new WebHyperlink("www.google.com");
text.Hyperlink = link;
text.Margin.Left = -48;
text.Margin.Top = 687;
text.Margin.Bottom = -150;
text.TextState.Underline = true;
text.TextState.FontSize = 11;

text.TextState.ForegroundColor = Aspose.Pdf.Color.DeepSkyBlue;
text.TextState.BackgroundColor = Aspose.Pdf.Color.White;
page.Paragraphs.Add(text);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57215859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档