Aspose.Cells对PDF文件加密(代码示例)

原创|其它|编辑:郝浩|2012-09-10 15:40:09.000|阅读 1501 次

概述:为了保证文件的安全性,我们通常都希望对自己的PDF文件进行加密,所以,文件加密功能是非常实用的。下面,慧都控件网就和大家一起来分享执行PDF文件加密操作的事例代码,供大家参考:

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>

为了保证文件的安全性,我们通常都希望对自己的PDF文件进行加密,所以,文件加密功能是非常实用的。下面,慧都控件网就和大家一起来分享Aspose.Cells执行PDF文件加密操作的事例代码,供大家参考:

[C#]

 //Open an Excel file
Workbook workbook = new Workbook("e:\\test\\book1.xls");

//Instantiate PDFSaveOptions to manage security attributes
PdfSaveOptions saveOption = new PdfSaveOptions();

saveOption.SecurityOptions = new Aspose.Cells.Rendering.PdfSecurity.PdfSecurityOptions();
//Set the user password
saveOption.SecurityOptions.UserPassword = "user";

//Set the owner password
saveOption.SecurityOptions.OwnerPassword = "owner";

//Disable extracting content permission
saveOption.SecurityOptions.ExtractContentPermission = false;

//Disable print permission
saveOption.SecurityOptions.PrintPermission = false;

//Save the PDF document with encrypted settings
workbook.Save("e:\\test\\securepdf_test.pdf", saveOption);

[VB]

 'Open an Excel file
Dim workbook As New Workbook("e:\test\book1.xls")

'Instantiate PDFSaveOptions to manage security attributes
Dim saveOption As New PdfSaveOptions()

saveOption.SecurityOptions = New Aspose.Cells.Rendering.PdfSecurity.PdfSecurityOptions()
'Set the user password
saveOption.SecurityOptions.UserPassword = "user"

'Set the owner password
saveOption.SecurityOptions.OwnerPassword = "owner"

'Disable extracting content permission
saveOption.SecurityOptions.ExtractContentPermission = False

'Disable print permission
saveOption.SecurityOptions.PrintPermission = False

'Save the PDF document with encrypted settings
workbook.Save("e:\test\securepdf_test.pdf", saveOption)


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP