首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Aspose.Pdf库超链接生成受密码保护的PDF

使用Aspose.Pdf库超链接生成受密码保护的PDF
EN

Stack Overflow用户
提问于 2016-07-16 12:52:50
回答 1查看 434关注 0票数 0

我希望有人能帮助我解决一个问题,我正在生成一个密码保护的PDF与超链接与Aspose.Pdf库。问题是密码保护似乎破坏了…的超链接。

以下代码工作正常(没有任何密码保护):

代码语言:javascript
复制
// create new PDF doc with hyperlink in
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Aspose.Pdf.Page page = doc.Pages.Add();
Aspose.Pdf.Text.TextFragment textFragment = new Aspose.Pdf.Text.TextFragment("hyperlink test");
textFragment.Hyperlink = new Aspose.Pdf.WebHyperlink("https://www.google.co.uk/");
page.Paragraphs.Add(textFragment);

// password protect the PDF
// Aspose.Pdf.Permissions permission = (Aspose.Pdf.Permissions.PrintingQuality | Aspose.Pdf.Permissions.PrintDocument | Aspose.Pdf.Permissions.ModifyTextAnnotations | Aspose.Pdf.Permissions.FillForm | Aspose.Pdf.Permissions.ModifyContent | Aspose.Pdf.Permissions.ExtractContent | Aspose.Pdf.Permissions.AssembleDocument);
// doc.Encrypt("pass1", "pass2", permission, Aspose.Pdf.CryptoAlgorithm.RC4x128);

// save the doc
doc.Save("C:\\temp\\PDFHyperlink\\test.pdf");

生成的PDF可以成功地打开浏览器并导航到google。

但是,如果取消密码保护PDF的行的注释,超链接就会被破坏。

代码语言:javascript
复制
// create new PDF doc with hyperlink in
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Aspose.Pdf.Page page = doc.Pages.Add();
Aspose.Pdf.Text.TextFragment textFragment = new Aspose.Pdf.Text.TextFragment("hyperlink test");
textFragment.Hyperlink = new Aspose.Pdf.WebHyperlink("https://www.google.co.uk/");
page.Paragraphs.Add(textFragment);

// password protect the PDF
Aspose.Pdf.Permissions permission = (Aspose.Pdf.Permissions.PrintingQuality | Aspose.Pdf.Permissions.PrintDocument | Aspose.Pdf.Permissions.ModifyTextAnnotations | Aspose.Pdf.Permissions.FillForm | Aspose.Pdf.Permissions.ModifyContent | Aspose.Pdf.Permissions.ExtractContent | Aspose.Pdf.Permissions.AssembleDocument);
doc.Encrypt("pass1", "pass2", permission, Aspose.Pdf.CryptoAlgorithm.RC4x128);

// save the doc
doc.Save("C:\\temp\\PDFHyperlink\\test.pdf");

…当单击超链接时,您将得到以下消息:

…如果您单击允许,什么都不会发生!

我的密码保护PDF的方式有问题吗?任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2016-07-19 05:25:01

我已经测试了场景,并成功地复制了上述问题。为了更正起见,我已经在我们的问题跟踪系统中以PDFNET-41159的身份记录了它。我们将进一步调查这一问题的细节,并将随时向您通报纠正的状况。请耐心等待决议。

我的名字是Nayyer,我是Aspose的开发者传道者。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38411416

复制
相关文章

相似问题

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