Quick Start (MTOM): Modifying a signature field using the web service API

The following C# code example modifies a signature field named SignatureField1 by locking all fields in the form when a signature is applied to the signature field and ensuring that no changes are allowed. After the Signature service returns the PDF document that contains the modified signature field, the PDF document is saved as a PDF file named LoanSig.pdf. (This example overwrites the PDF file that is passed to the Signature service.) (See Modifying Signature Fields.)

    * 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; 
using ModifySignatureField.ServiceReference1; 
namespace ModifySignatureField 
       class Program 
           static void Main(string[] args) 
                   //Create a SignatureServiceClient object 
                   SignatureServiceClient sigClient = new SignatureServiceClient(); 
                   sigClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/SignatureService?blob=mtom"); 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)sigClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   sigClient.ClientCredentials.UserName.UserName = "administrator"; 
                   sigClient.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 object to store a PDF document that contains  
                //a signature field to modify 
                BLOB inDoc = new BLOB(); 
                //Specify a PDF document that contains a signature field to modify 
                string path = "C:\\Adobe\LoanSig.pdf"; 
                FileStream fs = new FileStream(path, 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 file stream 
                fs.Read(byteArray, 0, len); 
                //Populate the BLOB object 
                inDoc.MTOM = byteArray; 
                //Specify the name of the signature field 
                string fieldName = "SignatureField1"; 
                //Create a PDFSignatureFieldProperties 
                PDFSignatureFieldProperties fieldProperties = new PDFSignatureFieldProperties(); 
                //Create a PDFSeedValueOptionSpec object that stores  
                //seed value dictionary information. 
                PDFSeedValueOptionSpec seedOptionsSpec = new PDFSeedValueOptionSpec(); 
                //Disallow changes to the PDF document. Any change to the document invalidates  
                //the signature 
                seedOptionsSpec.mdpValue = MDPPermissions.NoChanges; 
                //Create a FieldMDPOptionSpec object that stores  
                //signature field lock dictionary information 
                FieldMDPOptionSpec fieldMDPOptionsSpec = new FieldMDPOptionSpec();     
                //Lock all fields in the PDF document 
                fieldMDPOptionsSpec.action = FieldMDPAction.ALL; 
                //Set dictionary information 
                fieldProperties.seedValue = seedOptionsSpec; 
                fieldProperties.fieldMDP = fieldMDPOptionsSpec; 
                //Add a signature field to the PDF document 
                   BLOB sigFieldPDF = sigClient.modifySignatureField(inDoc, fieldName, fieldProperties); 
                //Populate a byte array with the contents of the BLOB object 
                byte[] outByteArray = sigFieldPDF.MTOM; 
                //Save the PDF document that contains the signature field         
                string FILE_NAME = "C:\\Adobe\Loan.pdf"; 
                FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate); 
                BinaryWriter w = new BinaryWriter(fs2); 
               catch (Exception ee) 

// Ethnio survey code removed