API Quick Starts (Code Examples) > Form Data Integration Service API Quick Starts > Quick Start: Importing form data using the web service API

Quick Start: Importing form data using the web service API
The following C# code example imports data into a PDF form. The data is located in an XML file named XDPData.xml and the PDF form is saved as ResultLoanForm.pdf. (See Importing Form Data.)
/*
 * 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 ; 
 
namespace DataIntegration
{
	class ImportData
	{
		[STAThread]
		static void Main(string[] args)
		{
		try
		{
			//Create a FormDataIntegrationService object and set 
			//authentication values
			FormDataIntegrationService dataIntClient = new FormDataIntegrationService();
			dataIntClient.Credentials = new System.Net.NetworkCredential("administrator", "password");
		
			//Import XDP XML data into an XFA PDF document
			BLOB inXMLData = new BLOB();
			string path = "C:\\Adobe\\XDPData.xml";
			FileStream fsXML = new FileStream(path, FileMode.Open);
	
			//Get the length of the file stream 
			int lenXML = (int)fsXML.Length; 
			byte[] byteXML=new byte[lenXML];
 
			//Populate the byte array with the contents of the FileStream
			fsXML.Read(byteXML, 0, lenXML);
 
			//Populate the BLOB object
			inXMLData.binaryData = byteXML; 
 
			//Create a BLOB that represents the input PDF form
			BLOB inPDFForm = new BLOB();
 
			//Get the XDP XML data source
			string pathPDF = "C:\\Adobe\\Loan.pdf";
			FileStream fsPDF = new FileStream(pathPDF, FileMode.Open);
	
			//Get the length of the file stream 
			int lenPDF = (int)fsPDF.Length; 
			byte[] bytePDF =new byte[lenPDF];
 
			//Populate the byte array with the contents of the FileStream
			fsPDF.Read(bytePDF, 0, lenPDF);
 
			//Populate the BLOB object
			inPDFForm.binaryData =bytePDF; 
 
			//Import data into the PDF form
			BLOB result = dataIntClient.importData(inPDFForm,inXMLData);
 
			//Populate a byte array with form data located in the BLOB object
			byte[] outByteArray = result.binaryData;
 
			//Save the form as ResultLoanForm.pdf
			string FILE_NAME = "C:\\ResultLoanForm.pdf";
			FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate);
			BinaryWriter w = new BinaryWriter(fs2);
			w.Write(outByteArray);
			w.Close();
			fs2.Close();
			}
		catch(Exception ee)	
			{
			Console.WriteLine("An unexpected exception was encountered: "+ee.Message + "\n" + ee.StackTrace);
			}
		}
	}
}
 

API Quick Starts (Code Examples) > Form Data Integration Service API Quick Starts > Quick Start: Importing form data using the web service API

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/000046.html