原創(chuàng)|使用教程|編輯:何躍|2021-09-17 14:34:53.853|閱讀 264 次
概述:使用LEADTOOLS提供的PDFFile類也使PDF加密、解密和密碼保護(hù)變得簡(jiǎn)單!
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
使用LEADTOOLS提供的PDFFile類也使PDF加密、解密和密碼保護(hù)變得簡(jiǎn)單!
Leadtools提供兩種類型的PDF密碼保護(hù)。
private static void Main(string[] args) { // Check to make sure number of args is correct, files exist, etc... if (FailsPreFlight(args)) return; try { ProtectPdfFile(args[0], args[1]); } catch (Exception ex) { Console.WriteLine(ex.Message); } } private static void ProtectPdfFile(string destinationPdf, string sourcePdf) { string sourcePdfPassword = PDFFile.IsEncrypted(sourcePdf) ? "User_9@55w0Rd" : ""; new PDFFile(sourcePdf, sourcePdfPassword) { SecurityOptions = new PDFSecurityOptions { UserPassword = "User_9@55w0Rd", OwnerPassword = "Owner_9@55w0Rd", EncryptionMode = PDFEncryptionMode.RC128Bit, AssemblyEnabled = false, AnnotationsEnabled = true, CopyEnabled = false, CopyForAccessibilityEnabled = false, EditEnabled = false, PrintEnabled = false, HighQualityPrintEnabled = false, FormFieldFillingEnabled = false } }.Convert(1, -1, destinationPdf); }2. 在VB中加密PDF
Dim sourcePdfPassword As String = If(PDFFile.IsEncrypted(sourcePdf), "User_9@55w0Rd", "") New PDFFile(sourcePdf, sourcePdfPassword) With { .SecurityOptions = New PDFSecurityOptions With { .UserPassword = "User_9@55w0Rd", .OwnerPassword = "Owner_9@55w0Rd", .EncryptionMode = PDFEncryptionMode.RC128Bit, .AssemblyEnabled = False, .AnnotationsEnabled = True, .CopyEnabled = False, .CopyForAccessibilityEnabled = False, .EditEnabled = False, .PrintEnabled = False, .HighQualityPrintEnabled = False, .FormFieldFillingEnabled = False } }.Convert(1, -1, destinationPdf)
3. 在Java中加密PDF
String sourcePdfPassword = PDFFile.isEncrypted(sourcePdf) ? "User_9@55w0Rd" : ""; PDFSecurityOptions securityOptions = new PDFSecurityOptions(); securityOptions.setUserPassword("User_9@55w0Rd"); securityOptions.setOwnerPassword("Owner_9@55w0Rd"); securityOptions.setEncryptionMode(PDFEncryptionMode.RC128_BIT); securityOptions.setAssemblyEnabled(false); securityOptions.setAnnotationsEnabled(true); securityOptions.setCopyEnabled(false); securityOptions.setCopyForAccessibilityEnabled(false); securityOptions.setEditEnabled(false); securityOptions.setFormFieldFillingEnabled(false); securityOptions.setHighQualityPrintEnabled(false); securityOptions.setPrintEnabled(false); PDFFile pdfFile = new PDFFile(sourcePdf, sourcePdfPassword); pdfFile.setSecurityOptions(securityOptions); pdfFile.convert(1, -1, destinationPdf);這里用到的SDK是LEADTOOLS PDF Pro Developer Toolkit,點(diǎn)擊這里即可下載。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn