The following Java code example invokes a process named EncryptDocument using Axis-generated files that use 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./** This Java Quick Start uses axis generated Java files and* base64 encoding.)* For complete details,* see "Invoking LiveCycle ES using Base64 Encoding" in* Programming with LiveCycle ES*/import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import com.adobe.idp.services.BLOB;import com.adobe.idp.services.EncryptDocument;import com.adobe.idp.services.EncryptDocumentServiceLocator;public class InvokeDocumentEncryptBase64 {public static void main(String[] args) {try{String pdfFile = "C:\\Adobe\\map.pdf";String encryptedPDF = "C:\\Adobe\\mapEncrypt.pdf";//create a service locatorEncryptDocumentServiceLocator locate = new EncryptDocumentServiceLocator();//specify the service target URL and object typeEncryptDocument encryptionClient = locate.getEncryptDocument();//Use the binding stub with the locator((javax.xml.rpc.Stub)encryptionClient)._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, "administrator");((javax.xml.rpc.Stub)encryptionClient)._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, "password");//Reference the PDF document to pass to the EncrptDocuemnt processFileInputStream file = new FileInputStream(pdfFile);//Create a byte array to store the PDF documentint len = file.available();byte [] myByteArray = new byte[len];int i = 0;while (i < len) {i += file.read(myByteArray, i, len);}//Create a BLOB object and populate it with the byte arrayBLOB inDoc = new BLOB();inDoc.setBinaryData(myByteArray);//Invoke the EncryptDocument processBLOB outDoc = encryptionClient.invoke(inDoc);//Populate a byte array with the encrypted PDF documentbyte[] myFile = outDoc.getBinaryData();//Create a File objectFile outFile = new File(encryptedPDF);//Create a FileOutputStream object.FileOutputStream myFileW = new FileOutputStream(outFile);//Call the FileOutputStream object's write method and pass the pdf datamyFileW.write(myFile);//Close the FileOutputStream objectmyFileW.close();}catch (Exception e) {e.printStackTrace();}}}
| 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/000010.html