Quick Start (MTOM): Converting a PostScript file to a PDF document using the web service API

The following C# .NET code example converts a PostScript file called Loan.ps to a PDF document calledLoan.pdf. (See Converting PostScript to PDF documents.)

    * Ensure that you create a .NET project that uses  
    * MS Visual Studio 2008 and version 3.5 of the .NET 
    * framework. This is required to invoke a  
    * LiveCycle service using MTOM. 
    * For information, see "Invoking LiveCycle using MTOM" in Programming with LiveCycle   
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.ServiceModel; 
using System.IO; 
//A reference to the Output service  
using ConvertPDF.ServiceReference1; 
namespace CreatePDF 
       class Program 
           static void Main(string[] args) 
                   //Create a DistillerServiceClient object 
                   DistillerServiceClient distillerClient = new DistillerServiceClient(); 
                   distillerClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/DistillerService?blob=mtom"); 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)distillerClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   distillerClient.ClientCredentials.UserName.UserName = "administrator"; 
                   distillerClient.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; 
                   //Create a BLOB that represents the input PS file 
                   BLOB inDoc = new BLOB(); 
                   //Get the input PS document 
                   string inputFileName = "C:\\Adobe\Loan.ps"; 
                   FileStream fs = new FileStream(inputFileName, FileMode.Open); 
                   //Get the length of the file stream and create a byte array  
                   int len = (int)fs.Length; 
                   byte[] byteArray = new byte[len]; 
                   //Populate the byte array with the contents of the file stream 
                   fs.Read(byteArray, 0, len); 
                   //Populate the BLOB object 
                   inDoc.MTOM = byteArray; 
                   //Specify the PDF and security settings 
                   String adobePDFSettings = "Standard"; 
                   String securitySettings = "No Security"; 
                   //Prepare output parameters 
                   BLOB createdDocument = new BLOB(); 
                   BLOB logDocument = new BLOB();  
                   //Send the conversion request to the Distiller Service 
                       out createdDocument, 
                       out logDocument); 
                   //Populate a byte array with the BLOB 
                   byte[] outByteArray = createdDocument.MTOM; 
                   //Create a new file containing the returned PDF document 
                   string FILE_NAME = "C:\\Adobe\Loan.pdf"; 
                   FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate); 
                   BinaryWriter w = new BinaryWriter(fs2); 
                   Console.WriteLine("The PS file was converted to a PDF document"); 
               catch (Exception ee) 

// Ethnio survey code removed