The following C# code example invokes a process named EncryptDocument from a Microsoft .NET project using Base64 encoding. (See Invoking LiveCycle ES using Base64 Encoding.)An unsecured PDF document based on a PDF file named map.pdf is passed to the LiveCycle ES process. The process returns a password-encrypted PDF document that is saved as a PDF file named mapEncrypt.pdf./** Ensure that you create a .NET client assembly that uses* base64 encoding. This is required to populate a BLOB* object with data or retrieve data from a BLOB object.** For information, see "Invoking LiveCycle ES using Base64 Encoding" in* Programming with LiveCycle ES*/using System;using System.Collections;using System.ComponentModel;using System.Data;using System.IO;namespace ConsoleApplication1{class InvokeEncryptDocumentUsingBase64{const int BUFFER_SIZE = 4096;[STAThread]static void Main(string[] args){try{String pdfFile = "C:\\Adobe\\map.pdf";String encryptedPDF = "C:\\Adobe\\mapEncrypt.pdf";//Create an EncryptDocumentServiceWse object and set authentication valuesEncryptDocumentService encryptClient = new EncryptDocumentService();encryptClient.Credentials = new System.Net.NetworkCredential("administrator", "password");//Reference the PDF file to send to the EncryptDocument processFileStream fs = new FileStream(pdfFile, FileMode.Open);//Create a BLOB objectBLOB inDoc = new BLOB();//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;//Invoke the EncryptDocument processBLOB outDoc = encryptClient.invoke(inDoc);//Populate a byte array with BLOB databyte[] outByteArray = outDoc.binaryData;//Create a new file named UsageRightsLoan.pdfFileStream fs2 = new FileStream(encryptedPDF, FileMode.OpenOrCreate);//Create a BinaryWriter objectBinaryWriter w = new BinaryWriter(fs2);w.Write(outByteArray);w.Close();fs2.Close();}catch (Exception ee){Console.WriteLine(ee.Message);}}}}
| Programming with LiveCycle ES (LiveDocs) |
| Adobe LiveCycle ES Update 1 |
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/000009.html