|
|
The following C# code example determines the type of encryption that is protecting a PDF document named EncryptLoan.pdf.using System;using System.Collections;using System.ComponentModel;using System.Data;using System.IO ;namespace GetEncryptionType{class Class1{[STAThread]static void Main(string[] args){try{//Create an EncryptionServiceService client objectEncryptionServiceService encryptionClient = new EncryptionServiceService();encryptionClient.Credentials = new System.Net.NetworkCredential("administrator", "password");//Create a BLOB object to store the PDF documentBLOB inDoc = new BLOB();//Specify the PDF documentstring path = "C:\\Adobe\\EncryptLoan.pdf";FileStream fs = new FileStream(path, FileMode.Open);//Get the length of the file streamint len = (int)fs.Length;byte[] ByteArray=new byte[len];//Populate the byte array with the contents of the FileStream objectfs.Read(ByteArray, 0, len);inDoc.binaryData = ByteArray;//Determine the encryption typeEncryptionTypeResult encryptTypeResult = encryptionClient.getPDFEncryption(inDoc);if (encryptTypeResult.encryptionType == EncryptionType.PASSWORD)Console.WriteLine("The PDF document is protected with password-based encryption");else if (encryptTypeResult.encryptionType == EncryptionType.POLICY_SERVER)Console.WriteLine("The PDF document is protected with policy");else if (encryptTypeResult.encryptionType == EncryptionType.CERTIFICATE)Console.WriteLine("The PDF document is protected with certificate-based encryption");else if (encryptTypeResult.encryptionType == EncryptionType.OTHER)Console.WriteLine("The PDF document is protected with another type of encryption");else if (encryptTypeResult.encryptionType == EncryptionType.NONE)Console.WriteLine("The PDF document is not protected.");}catch (Exception ee){Console.WriteLine(ee.Message);}}}}
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/quickStarts_Encryption.8.9.html