Quick Start (MTOM): Rendering an interactive PDF document using the web service API

The following C# quick start retrieves the file Loan.xdp located in C:\Adobe. This file is used to populate the BLOB object’s MTOM field. The BLOB object is passed to the FormServiceClient object’s renderPDFForm2 method. The interactive form is saved as a PDF file named Loan.pdf. This web service quick start uses MTOM. (See Invoking LiveCycle using MTOM.)

???using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.ServiceModel; 
using System.IO; 
using RenderPDFForm.ServiceReference1; 
 
namespace RenderPDFForm 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Create a FormsServiceClient object 
                   FormsServiceClient formsClient = new FormsServiceClient(); 
                   formsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/FormsService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)formsClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   formsClient.ClientCredentials.UserName.UserName = "administrator"; 
                   formsClient.ClientCredentials.UserName.Password = "password"; 
                   b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
                   b.MaxReceivedMessageSize = 2000000; 
                   b.MaxBufferSize = 2000000; 
                   b.ReaderQuotas.MaxArrayLength = 2000000; 
 
                   //Reference the XDP document to render 
                   string inputFileName = "C:\\Adobe\Loan.xdp"; 
                   FileStream fs = new FileStream(inputFileName, FileMode.Open); 
 
                   //Get the length of the file stream  
                   int len = (int)fs.Length; 
                   byte[] ByteArray = new byte[len]; 
 
                   //Populate the byte array with the contents of the FileStream object 
                   fs.Read(ByteArray, 0, len); 
                   BLOB inDoc = new BLOB(); 
                   inDoc.MTOM = ByteArray; 
     
                   //Set run-time options 
                   PDFFormRenderSpec renderSpec = new PDFFormRenderSpec(); 
                   renderSpec.generateServerAppearance = true; 
 
                   //Set out parameter values 
                   long pageCount = 1; 
                   String localeValue = "en_US"; 
                   FormsResult result = new FormsResult(); 
 
                   //Render an interactive PDF form by ivoking the renderPDFForm2 method 
                   formsClient.renderPDFForm2( 
                       inDoc, 
                       null, 
                       renderSpec, 
                       null, 
                       null, 
                       out pageCount, 
                       out localeValue, 
                       out result); 
 
                   //Populate a byte array with BLOB data 
                   RenderPDFForm.ServiceReference1.BLOB outDoc = result.outputContent; 
                   byte[] outByteArray = outDoc.MTOM; 
 
                   //Save the interactive form as a PDF file 
                   string fileName = "C:\\Adobe\Loan.pdf"; 
                   FileStream fs2 = new FileStream(fileName, FileMode.OpenOrCreate); 
 
                   //Create a BinaryWriter object 
                   BinaryWriter w = new BinaryWriter(fs2); 
                   w.Write(outByteArray); 
                   w.Close(); 
                   fs2.Close(); 
               } 
 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
} 

// Ethnio survey code removed