翻譯|行業(yè)資訊|編輯:胡濤|2023-12-28 11:34:32.293|閱讀 69 次
概述:時。Spire.PDF for .NET使您能夠用 C#、VB.NET 修改加密 PDF 文件的密碼。您可以修改所有者密碼和用戶密碼,并設置訪問 PDF 文件時的用戶限制。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
修改PDF文件的密碼確實是一個理性的選擇,尤其是當密碼被某人知道并且您的PDF文件不再安全時。Spire.PDF for .NET使您能夠用 C#、VB.NET 修改加密 PDF 文件的密碼。您可以修改所有者密碼和用戶密碼,并設置訪問 PDF 文件時的用戶限制。現在請看修改加密PDF密碼的過程,如下圖:
Spire.PDF for .NET 是一款獨立 PDF 控件,用于 .NET 程序中創(chuàng)建、編輯和操作 PDF 文檔。使用 Spire.PDF 類庫,開發(fā)人員可以新建一個 PDF 文檔或者對現有的 PDF 文檔進行處理,且無需安裝 Adobe Acrobat。
E-iceblue 功能類庫Spire 系列文檔處理組件均由中國本土團隊研發(fā),不依賴第三方軟件,不受其他國家的技術或法律法規(guī)限制,同時適配國產操作系統如中科方德、中標麒麟等,兼容國產文檔處理軟件 WPS(如 .wps/.et/.dps 等格式
Spire.PDF for.net下載 Spire.PDF for java下載
從上圖中,您可以很容易地發(fā)現,第一步是通過所有者密碼解密PDF文件。所以原來的所有者密碼是必要的。您可以通過以下方法解密:Spire.Pdf.PdfDocument(string filename, string password)
然后,通過重置所有者密碼和用戶密碼來修改密碼。Spire.PDFDocument.Security命名空間中的PDFSecurity類不僅可以幫助您設置所有者密碼和用戶密碼,還可以設置用戶權限以限制用戶訪問。
下面是修改加密PDF文件密碼的完整代碼,請先下載Spire.PDF for .NET并將其安裝在系統上,然后再執(zhí)行以下代碼:
[C#]
using Spire.Pdf; using Spire.Pdf.Security; namespace modify_PDF_passwords { class Program { static void Main(string[] args) { //load a encrypted file and decrypt it String encryptedPdf = @"..\Encrypt.pdf"; PdfDocument doc = new PdfDocument(encryptedPdf, "e-iceblue"); //reset PDF passwords and set user password permission doc.Security.OwnerPassword = "Spire.PDF"; doc.Security.UserPassword = "pdfcomponent"; doc.Security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FillFields; //Save pdf file. doc.SaveToFile("Encryption.pdf"); doc.Close(); //Launching the Pdf file. System.Diagnostics.Process.Start("Encryption.pdf"); } } }
[VB.NET]
Imports Spire.Pdf Imports Spire.Pdf.Security Namespace modify_PDF_passwords Class Program Private Shared Sub Main(args As String()) 'load a encrypted file and decrypt it Dim encryptedPdf As [String] = "..\Encrypt.pdf" Dim doc As New PdfDocument(encryptedPdf, "e-iceblue") 'reset PDF passwords and set user password permission doc.Security.OwnerPassword = "Spire.PDF" doc.Security.UserPassword = "pdfcomponent" doc.Security.Permissions = PdfPermissionsFlags.Print Or PdfPermissionsFlags.FillFields 'Save pdf file. doc.SaveToFile("Encryption.pdf") doc.Close() 'Launching the Pdf file. System.Diagnostics.Process.Start("Encryption.pdf") End Sub End Class End Namespace
以上便是如何修改加密PDF的密碼,如果您有其他問題也可以繼續(xù)瀏覽本系列文章,獲取相關教程,你還可以給我留言或者加入我們的官方技術交流群。
歡迎下載|體驗更多E-iceblue產品
獲取更多信息請咨詢 ;技術交流Q群(767755948)
本站文章除注明轉載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn