I wrote a test C# web application (with a lot of guidance from a SmartDoc Technologies article and the Adobe "Developing Custom Applications" document) that displays a page which contains a pdf document. You can display a pre-populated PDF by entering data as html input. You can also change the data on the PDF, and extract the data and display this information.<br /><br />Download the sample code from the Developing a .NET web application using Adobe LiveCycle Forms article at
http://www.smartdoctech.com/articles.aspx.<br /><br />Place your PDF file on the LiveCycle Forms server. I put mine in D:\Adobe\LiveCycle\template.<br /><br />Create a new web project.<br /><br />Make a reference to the ICSharpCode.SharpZipLib.dll and SoupClient.dll in the sample code bin folder.<br /><br />TESTPAGE2 CODE IS USED TO DISPLAY A BLANK AND PRE-POPULATED PDF:<br /><br />using SoapClient;<br />using CM = System.Configuration.ConfigurationManager;<br /><br />protected void Page_Load(object sender, EventArgs e)<br />{<br /> if (Request.QueryString["extract"] == null || Request.QueryString["extract"].Trim().Length == 0)<br /> {<br /> DisplayPDF();<br /> }<br /> else<br /> {<br /> ExtractPdfData();<br /> }<br />}<br /><br />string _SoapEndPoint = "http://your_server_name:8080/jboss-net/services/AdobeFSService";<br /><br />private void DisplayPDF()<br />{<br /> // Create an FSSoapClient object.<br /> FSSoapClient formServer = new FSSoapClient();<br /> formServer.setSoapEndPoint(_SoapEndPoint);<br /><br /> // Declare and populate local variables to pass to renderForm.<br /> String sFormQuery = "Target.pdf"; //Defines the form design to render<br /> String sFormPreference = "PDFForm"; //Defines the preference option<br /> String sContentRootURI = "D:\\Adobe\\LiveCycle\\template\\";<br /> String sTargetURL = "";<br /> String sApplicationWebRoot = "";<br /><br /> byte[] cData;<br /><br /> try<br /> {<br /> if (Request.QueryString["id"] == null || Request.QueryString["id"].Trim().Length == 0)<br /> {<br /> // Do not prepopulate the form.<br /> cData = new byte[0];<br /> }<br /> else<br /> {<br /> // Extract data from database.<br /> cData = GetData(Request.QueryString["id"]);<br /> }<br /><br /> //Call renderForm<br /> IOutputContext myOutputContext = formServer.renderForm(<br /> sFormQuery, //sFormQuery<br /> sFormPreference, //sFormPreference<br /> cData, //cData,<br /> "CacheEnabled=False",//sOptions<br /> null, //sUserAgent,<br /> sApplicationWebRoot, //sApplicationWebRoot<br /> sTargetURL, //sTargetURL<br /> sContentRootURI, //sContentRootURI<br /> null //sBaseURL<br /> );<br /><br /> //Create a byte array. Call the IOutputContext interface's<br /> //getOutputContext method<br /> byte[] cContent = myOutputContext.getOutputContent();<br /> Response.ContentType = "Application/pdf";<br /> Response.AddHeader("Content-Length", cContent.Length.ToString());<br /><br /> //Write a byte stream back to the web browser. Pass the byte array<br /> Response.BinaryWrite(cContent);<br /> Response.End();<br /> }<br /> //Catch a thrown exception<br /> catch (Exception ex)<br /> {<br /> byte[] bArray = (new System.Text.ASCIIEncoding()).GetBytes(ex.Message);<br /> Response.BinaryWrite(bArray);<br /> }<br />}<br /><br />/// <summary><br />/// Extracts data from database and returns an encoded sequence of bytes.<br />/// </summary><br />/// <returns></returns><br />public byte[] GetData(string pgaID)<br />{<br /> StringBuilder sb = new StringBuilder("");<br /> sb.Append("SELECT field as myfieldname, ");<br /> sb.Append("FROM table ");<br /> sb.Append("WHERE condition1 = true ");<br /> sb.Append("AND field_id = ");<br /> sb.Append(pgaID);<br /> sb.Append(" AND condition2 = true");<br /><br /> string sql = sb.ToString();<br /><br /> string conString = CM.ConnectionStrings["OAM_Connection"].ConnectionString;<br /> AseConnection con = new AseConnection(conString);<br /> AseCommand cmd = new AseCommand(sql, con);<br /> cmd.CommandType = CommandType.Text;<br /><br /> AseDataAdapter da = new AseDataAdapter(cmd);<br /> DataSet ds = new DataSet();<br /><br /> try<br /> {<br /> con.Open();<br /> da.Fill(ds, "XML_Root_Name");<br /> ds.DataSetName = "REMOVE";<br /> }<br /> catch<br /> {<br /> throw;<br /> }<br /> finally<br /> {<br /> con.Close();<br /> }<br /><br /> // Convert the dataset to XML.<br /> XmlDataDocument datadoc = new XmlDataDocument(ds);<br /> string dsXML = datadoc.InnerXml;<br /><br /> // Remove root element of Dataset.<br /> if (dsXML.Length > 17)<br /> {<br /> dsXML = dsXML.Remove(0, 8);<br /> dsXML = dsXML.Remove(dsXML.Length - 9);<br /> }<br /><br /> return Encoding.ASCII.GetBytes(dsXML);<br /><br />}<br /><br />TESTPAGE2 ALSO IS CALLED DIRECTLY BY THE PDF. <br /><br />private void ExtractPdfData()<br />{<br /> try<br /> {<br /> //Create an FSSoapClient object<br /> FSSoapClient formServer = new FSSoapClient();<br /> formServer.setSoapEndPoint(_SoapEndPoint);<br /><br /> // Call processFormSubmission to handle the submitted data. Pass the<br /> // Request object<br /> IOutputContext myOutputContext = formServer.processFormSubmission(Request, "OutputType=0");<br /> //Populate a byte array by calling IOutputContext objects<br /> //getOutContent method<br /> byte[] formOutput = myOutputContext.getOutputContent();<br /> //Create a MemoryStream object<br /> MemoryStream myMemoryStream = new MemoryStream(formOutput);<br /> // Create an XmlDocument object<br /> XmlDocument myDOM = new XmlDocument();<br /> // Load the XML data into the XmlDocument object:<br /> myDOM.Load(myMemoryStream);<br /> // Call getNodeText for each field in the form<br /> String clientName = getNodeText("fieldname1", myDOM);<br /> String question1 = getNodeText("fieldname2", myDOM);<br /><br /> StringBuilder sb = new StringBuilder("");<br /> sb.Append("<h2>You selected:</h2>");<br /> sb.Append("Field 1: " + fieldname1 + "<br>");<br /> sb.Append("Field 2: " + fieldname2 + "<br>");<br /><br /> Response.Write(sb.ToString());<br /> }//End of try statement<br /><br /> catch (Exception ioEx)<br /> {<br /> Response.Write("Exception error is: " + ioEx);<br /> }<br />}<br /><br />// Create the getNodeText custom method<br />private String getNodeText(String nodeName, XmlDocument myDOM)<br />{<br /> //Get the node by name. nodeName is the name of the<br /> //node passed to this method<br /> XmlNodeList nl = myDOM.GetElementsByTagName(nodeName);<br /> XmlNode myNode = nl.Item(0);<br /> return myNode.InnerText;<br />}//End of getNodeText<br /><br />Default.aspx UI CODE, Blank.pdf is used for the initial display - located in web project:<br /><br /><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><br /><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><br /><html xmlns="http://www.w3.org/1999/xhtml" ><br /><head runat="server"><br /> <title>LiveCycle Demo</title><br /><br /> <script language="javascript" type="text/javascript"><br /> <br /> function noenter() <br /> {<br /> // Returns False if enter key is pressed.<br /> return !(window.event && window.event.keyCode == 13); <br /> }<br /> <br /> function displayPDF()<br /> {<br /> var pdfContainer = document.getElementById("iframePDF");<br /> var myID = document.getElementById("myID").value;<br /> document.getElementById("myID").value = "";<br /> <br /> if ((myID == null) || (myID == ''))<br /> {<br /> // Display empty form.<br /> pdfContainer.src = "TestPage2.aspx";<br /> }<br /> else<br /> {<br /> // Display pre-populated form.<br /> pdfContainer.src = "TestPage2.aspx?id=" + pgaID;<br /> }<br /> }<br /> </script><br /><br /></head><br /><body><br /> <form id="form1" runat="server"><br /> <h2>Adobe LiveCycle PDF Demo</h2><br /> <button onclick="displayPDF()">Display PDF</button> ID: <br /> <input id="myID" type="text" style="width: 48px" onkeypress="return noenter()" /><br /> <br /><br /><br /> <div st