1 Reply Latest reply: Jan 1, 2014 6:30 AM by WASIL RSS

    How to create web service for interactive forms using Adobe forms in .NET

    Prasanthkrish Community Member

      Hello Sir,

       

      I am trying to implement interactive forms using Adobe forms in .NET

       

      Where can I find the below highlighted web service and it methods.

       

      ???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);

                     }

                 }

             }

      }

       

      Best Regards,

      prasanth.k