翻譯|行業資訊|編輯:胡濤|2024-01-16 10:34:52.120|閱讀 69 次
概述:本文演示如何在C# 和 VB.NET中使用Spire.PDF for .NET更改 PDF 文檔的安全權限。歡迎查閱~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
當您使用密碼保護 PDF 文檔時,您可以選擇指定一組權限。權限決定用戶如何與文件交互。例如,您可以對文檔應用權限以禁止用戶打印或使用剪切和粘貼操作。本文演示如何在C# 和 VB.NET中使用Spire.PDF for .NET更改 PDF 文檔的安全權限。
Spire.PDF for .NET 是一款獨立 PDF 控件,用于 .NET 程序中創建、編輯和操作 PDF 文檔。使用 Spire.PDF 類庫,開發人員可以新建一個 PDF 文檔或者對現有的 PDF 文檔進行處理,且無需安裝 Adobe Acrobat。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團隊研發,不依賴第三方軟件,不受其他國家的技術或法律法規限制,同時適配國產操作系統如中科方德、中標麒麟等,兼容國產文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
Spire.PDF for.net下載 Spire.PDF for java下載
首先,您需要將 Spire.PDF for .NET 包中包含的 DLL 文件添加為 .NET 項目中的引用。DLL 文件可以從此鏈接下載或通過NuGet安裝。
PM> Install-Package Spire.PDF
以下是使用 Spire.PDF for .NET 將安全權限應用于 PDF 文檔的步驟。
【C#】
using Spire.Pdf; using Spire.Pdf.Security; namespace ChangeSecurityPermission { class Program { static void Main(string[] args) { //Create a PdfDocument object PdfDocument doc = new PdfDocument(); //Load a sample PDF file doc.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf"); //Specify open password string openPsd = string.Empty; //Specify permission password string permissionPsd = "e-iceblue"; //Encrypt the document with open password and permission password, and set the permissions and encryption key size doc.Security.Encrypt(openPsd, permissionPsd, PdfPermissionsFlags.FullQualityPrint, PdfEncryptionKeySize.Key128Bit); //Save the document to another PDF file doc.SaveToFile("SecurityPermissions.pdf"); } } }
【VB.NET】
using Spire.Pdf; using Spire.Pdf.Security; namespace ChangeSecurityPermission { class Program { static void Main(string[] args) { //Create a PdfDocument object PdfDocument doc = new PdfDocument(); //Load a sample PDF file doc.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf"); //Specify open password string openPsd = string.Empty; //Specify permission password string permissionPsd = "e-iceblue"; //Encrypt the document with open password and permission password, and set the permissions and encryption key size doc.Security.Encrypt(openPsd, permissionPsd, PdfPermissionsFlags.FullQualityPrint, PdfEncryptionKeySize.Key128Bit); //Save the document to another PDF file doc.SaveToFile("SecurityPermissions.pdf"); } } }
以上便是如何使更改 PDF 文檔的安全權限,如果您有其他問題也可以繼續瀏覽本系列文章,獲取相關教程,你還可以給我留言或者加入我們的官方技術交流群。
歡迎下載|體驗更多E-iceblue產品
獲取更多信息請咨詢 ;技術交流Q群(767755948)
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn