修改加密 PDF 的密碼
Spire.PDF for .NET 是一款專門對 Word 文檔進(jìn)行操作的 .NET 類庫。致力于在于幫助開發(fā)人員輕松快捷高效地創(chuàng)建、編輯、轉(zhuǎn)換和打印 Microsoft Word 文檔,而無需安裝 Microsoft Word。
行號用于在每行文本旁邊顯示 Word 自動計(jì)算的行數(shù)。當(dāng)我們需要參考合同或法律文件等文檔中的特定行時(shí),它非常有用。word中的行號功能允許我們設(shè)置起始值、編號間隔、與文本的距離以及行號的編號方式。使用 Spire.Doc,我們可以實(shí)現(xiàn)上述所有功能。本文將介紹如何將 HTML 轉(zhuǎn)換為 PDF。
歡迎加入spire技術(shù)交流群:767755948
修改 PDF 文件的密碼確實(shí)是一個(gè)理性的選擇,尤其是當(dāng)密碼已被他人知曉,您的 PDF 文件不再安全時(shí)。Spire.PDF for .NET能讓您在C#、VB.NET中修改加密PDF文件的密碼。您可以修改所有者密碼和用戶密碼,并在訪問 PDF 文件時(shí)設(shè)置用戶限制。現(xiàn)在請看下圖所示的修改加密 PDF 密碼的過程:
 
 
從上圖中,你不難發(fā)現(xiàn),第一步是通過所有者密碼解密 PDF 文件。原始的所有者密碼是重要的。你可以用這種方法解密:Spire.Pdf.PdfDocument(string filename, string password)
然后,通過重置所有者密碼和用戶密碼來修改密碼。命名空間 Spire.PDFDocument.Security 中的 PDFSecurity 類不僅可以幫助您設(shè)置所有者密碼和用戶密碼,還可以設(shè)置用戶權(quán)限以限制用戶訪問。
	下面顯示了修改加密 PDF 文件密碼的全部代碼,請下載 Spire.PDF for .NET 并安裝到系統(tǒng)上后再查看代碼:
[C#] 
	
	
01	using Spire.Pdf;
02	using Spire.Pdf.Security;
03	 
04	namespace modify_PDF_passwords
05	{
06	    class Program
07	    {
08	        static void Main(string[] args)
09	        {
10	 
11	            //load a encrypted file and decrypt it
12	            String encryptedPdf = @"..\Encrypt.pdf";
13	            PdfDocument doc = new PdfDocument(encryptedPdf, "e-iceblue");
14	 
15	            //reset PDF passwords and set user password permission
16	            doc.Security.OwnerPassword = "Spire.PDF";
17	            doc.Security.UserPassword = "pdfcomponent";
18	            doc.Security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FillFields;
19	 
20	            //Save pdf file.
21	            doc.SaveToFile("Encryption.pdf");
22	            doc.Close();
23	            //Launching the Pdf file.
24	            System.Diagnostics.Process.Start("Encryption.pdf");     
25	             
26	        }   
27	    }
28	}
[VB.NET]
01	Imports Spire.Pdf
02	Imports Spire.Pdf.Security
03	 
04	Namespace modify_PDF_passwords
05	    Class Program
06	        Private Shared Sub Main(args As String())
07	 
08	            'load a encrypted file and decrypt it
09	            Dim encryptedPdf As [String] = "..\Encrypt.pdf"
10	            Dim doc As New PdfDocument(encryptedPdf, "e-iceblue")
11	 
12	            'reset PDF passwords and set user password permission
13	            doc.Security.OwnerPassword = "Spire.PDF"
14	            doc.Security.UserPassword = "pdfcomponent"
15	            doc.Security.Permissions = PdfPermissionsFlags.Print Or PdfPermissionsFlags.FillFields
16	 
17	            'Save pdf file.
18	            doc.SaveToFile("Encryption.pdf")
19	            doc.Close()
20	            'Launching the Pdf file.
21	            System.Diagnostics.Process.Start("Encryption.pdf")
22	 
23	        End Sub
24	    End Class
25	End Namespace
Spire.PDF for .NET是一款.NET PDF組件,可讓您在C#、VB.NET中生成、讀取、編輯和處理PDF文件。
	
		
	
		
	
		
	

 QQ交談
QQ交談 在線咨詢
在線咨詢 
                 
                
 渝公網(wǎng)安備
            50010702500608號
渝公網(wǎng)安備
            50010702500608號
             
            
 客服熱線
客服熱線