使用Spire.PDF for .NET,咱們能夠輕鬆地加密PDF文檔,同時咱們還可使用Spire.PDF從C#和VB.NET中的加密PDF文檔中刪除密碼,咱們須要經過調用方法PdfDocument.LoadFromFile(string filename,string password)加載加密的PDF文件,而後將密碼設置爲空,以刪除密碼。html
首先,用用戶密碼查看PDF:加密
Step 1:加載受密碼保護的PDF文檔。htm
PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile("Sample.pdf", "e-iceblue");
Step 2:將密碼設置爲空,以刪除用戶密碼。blog
pdf.Security.UserPassword = string.Empty;
Step 3:將文檔保存到文件。圖片
pdf.SaveToFile("Decrypted.pdf");
從PDF文檔中刪除密碼後的有效屏幕截圖:文檔
完整代碼:get
[C#]string
PdfDocument pdf = new PdfDocument(); pdf.LoadFromFile("Sample.pdf", "e-iceblue"); pdf.Security.UserPassword = string.Empty; pdf.SaveToFile("Decrypted.pdf");
[VB.NET]it
Dim pdf As New PdfDocument() pdf.LoadFromFile("Sample.pdf", "e-iceblue") pdf.Security.UserPassword = String.Empty pdf.SaveToFile("Decrypted.pdf")
慧都控件網pdf