The following C# .NET example converts a PDF document named Loan.pdf to an RTF document named Loan.rtf. (See Converting HTML Documents to PDF Documents.)/** 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;using System.Web.Services;namespace GeneratePdfWSApp{class GeneratePdf_ExportPDF{[STAThread]static void Main(string[] args){try{// Create a GeneratePDFServiceServicee objectGeneratePDFServiceService svc = new GeneratePDFServiceService();// Provide authentication credentials to the servicesvc.Credentials = new System.Net.NetworkCredential("administrator","password");//Create a BLOB that stores the PDF document to convertBLOB inDoc = new BLOB();//Specify the location of the PDF documentstring inPath = "C:\\Adobe\\Loan.pdf";FileStream fs = new FileStream(inPath, FileMode.Open);//Get the length of the file streamint lenFS = (int)fs.Length;byte[] byteArray = new byte[lenFS];//Populate the byte array with the contents of the FileStream objectfs.Read(byteArray, 0, lenFS);inDoc.binaryData = byteArray;//Convert the PDF document to a RTF documentmapItem[] exportPDFResults = svc.ExportPDF(inDoc,inPath,"RTF",null);//Extract the newly created RTF documentBLOB outDoc = null;for (int i = 0; i < exportPDFResults.Length; i++){String myKey = (String)(exportPDFResults[i].key);if (myKey == "ConvertedDoc"){outDoc = (BLOB)(exportPDFResults[i].value);}}//Populate a byte array with the BLOBbyte[] outByteArray = outDoc.binaryData;//Create a new file containing the returned PDF documentstring FILE_NAME = "C:\\Adobe\\Loan.rtf";FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate);BinaryWriter w = new BinaryWriter(fs2);w.Write(outByteArray);w.Close();fs2.Close();Console.WriteLine("The PDF file was converted to a RTF document.");}catch (Exception ee){Console.WriteLine("An unexpected exception was encountered: " +ee.Message +"\n" +ee.StackTrace);}}}}
| 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/000096.html