Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Using Adobe LiveCycle Designer with ASP.NET to populate PDF Forms from Server Database.

Avatar

Level 8

[Thread Edited By Adobe]

/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here

Go ahead and to it now: https://adobe.ly/3eDnB4v */

 

Actual Question:

With Google, I did a very very long search on how to use Adobe LiveCycle Designer to design Interactive/Dynamic Forms, and publish them to the IIS Server and use ASP.NET to populate such forms with field values from back-end Database such as SQL Server.



We are designing and implementing Electronic Forms ASP.NET Application that must detect the user currently logged in to the Windows Intranet (under IIS), and should perform a Look-up to the Back-End Database to extract the User Related Data and Populate the Form Fields to start the Form Processing.



We have the following facts:

1. The forms will be designed using Adobe LiveCycle Designer 7.1.



2. We will NOT use Adobe LiveCycle Forms since it is not on our budget yet.



3. The users will have the required Adobe Acrobat version on the Client PC.



In a typical scenario, the user would go through these steps:



1. The user logs on to the Intranet using his Windows Login ID and Password. Then he starts the APS.NET Application for Forms Processing.



2. He will request a form to fill. The form may be populated with sensitive information such as Salary and only the requesting user must be able to see his Salary on any form.



3. On the server side, the system will use the User Windows ID to perform a query against the Back-End Database and generate the required XML Data.



4. The system must then link/merge the generated XML Data with the requested form and render (post) the form back to the user for further printing and/or submitting via email.



That's it !



I found an add-in product "Adobe LiveCycle® Designer add-in for Microsoft Visual Studio .NET" but it only wraps XPD forms in Visual Studio Component which is not of a great help to my requirements.



If any one could give me any hint on how to implement such requirements.



I truly appreciate any help.



Tarek.

275 Replies

Avatar

Level 8
>Matt W - 11:29am Mar 11, 08 PST (#30 of 30)



>Hi Tarek



>I just want to say thank you for the article it's been a great deal of help. I have only one question. Do you know of any way I can set the values of no fillible objects? For example. I want to fill in the submit URL of a button or change the text in a text object. Is this possible?

> (
Matt W, "Using Adobe LiveCycle Designer with ASP.NET to populate PDF Forms from Server Database." #3...)



First, I apologize for the delay in my reply.



If I follow you properly, you are looking way to assign a value to objects that cannot be filled from the user, such as the captions of the text box or the submit URL of the submit button. Is my understanding correct ?



Yes, everything is possible. Please give me a specific requirement with as much detail as possible, and I will try to help.



For example, assigning a value to the caption of a text box, is not a trivial as one might thing. You need to follow a special syntax to make it work.



If you need to assign a value to such objects, and the source of the value is from the back-end database, then you must pass this value in the same manner you are passing the other fields via XML, and then on the client side, using javascript, you need to access the data model and assign this value to the required object property.



In my case, I am currently hard-coding the submit URL in the form, and I am planning to change this and pass the URL from the server to the PDF Form because we have DEV and PROD servers and they must work independently.



Tarek.

Avatar

Former Community Member
Hello Terek, thanks for responding. You are understanding my situation perfectly. I have two requiremtns for the button. 1 Change the submit url and 2 Change the visibility. I also want to be able to change the text inside a label. I've been playing around with the iTextSharp library but it doesn't seem to have that capibility. Any examples you might have would be appreaciated.



Thank You,



Matt

Avatar

Former Community Member
How are you able to retrieve the entire pdf file after you submit to the ASPX page? I am able to retrieve the form fields but I don't see any "chunk" element that contains a pdf.



On submit, here is my javascript:

event.target.submitForm( {cURL: "http://localhost/EmployeeHire/TestPDF.aspx?SubmittedFormPart=1",bXDP:true, cSubmitAs:"XDP", aPackets:["datasets", "pdf"]});



When setting aPackets to dataset & pdf, the submit button does not seem to work/post any data to the aspx page. But works when I set it to "*". However, there is no "chunk" element.



Any help will be great. Thanks.

Avatar

Level 8
dsrirams, "Using Adobe LiveCycle Designer with ASP.NET to populate PDF Forms from Server Database." ...

>dsrirams - 3:13pm May 13, 08 PST (#33 of 33)

>

>How are you able to retrieve the entire pdf file after you submit to the ASPX page? I am able to retrieve the form fields but I dont see any "chunk" element that contains a pdf. Any help will be great. Thanks



From the PDF JavaScript, the command used to submit the PDF must include the required parameters to submit the Form Variables and PDF in Binary format. I have already posted the required Submit javaScript command earlier in this thread.



Tarek.

Avatar

Level 8
Just to re-assure... here is the JavaScript command I am using:



event.target.submitForm( {cURL: "http://blablabla/LeaveProcess.aspx?SubmittedFormPart=1", aPackets:["datasets","pdf"], cSubmitAs: "XDP"});



I have looked at the command you used, it is slightly different. Try my version and confirm.



When you debug your ASP.NET ASPX Page after submitting, and convert the request input stream into XML, you should see a chunk element (when you view the XML Variable in the watch window). If you still do not see such element, check the version of Adobe Client you are using. It should be at least version 7.0.5 or higher.



Tarek.

Avatar

Former Community Member
Tarek,

I added the javascript as you had provided. Also, I got the latest reader 8.1. Still the same result. I tried to debug the application, the pdf does not post the form. It does when I remove "pdf" from aPackets parameter. Any suggestions?

Is there anything that I need to for the pdf? I created the form using LiveCycle and saved the file. Is there anything else I need to do with the file? When I change the aPackets to "*", the form gets submited to the page and I can see a Template element but no chunck. Is there anything I am doing wrong?

Avatar

Former Community Member
I was going through Adobe Help and came across..



"Save rights required (): When submitting a

document as XDP from the Adobe Reader with

aPackets set to pdf (or *, which implies pdf), the

document must have document save rights."



Does this mean all my users must have professional adobe versions? I am trying to put a public webSite. Appreciate your thoughts and suggestions.

Avatar

Level 8
Yes, you are right. When you submit a form with PDF this means you can take a copy of the form and save it under different name. This is not allowed from Adobe Reader.



I think there is an option in Acrobat that Reder-Enable the Form. But as per what I remember, it may not work.



Your only option, if you want to receive a copy of the PDF (with the Form Data Fields) then you have to Reader-Enable the form using LiveCycle Reader Extensions Server, which is going to cost you. There might be other alternatives but I am afraid that you have to contact Adobe Technical Support/Sales to give you an advise in that regards.



Tarek.

Avatar

Former Community Member
is it possible to take a form and upload the xml data to a web server? I found a way to create an email with the .xml file and I found a way to save the data from a form as an .xml file using "xfa.host.exportData" but for the life of me I cant figure out how to post or upload the .xml file to a web server. The closest that I think I have to come to a solution is the "event.target.submitForm" code that was posted in this thread but I dont know what kind of .aspx code I need to write. Currently, the users have to fill in the form and save the file as a .xml file and then go to a .html page I wrote and browse to the .xml file and then click another button to upload the file to a sever, which is a .asp page



first is it possible to do what i want?



If so, do you have a sample or generic .aspx code you can post here? All i want is to create a button that posts the .xml file to a web server - even FTP will work but I need the whole .xml file.

Avatar

Level 8
Jeff,<br /><br />Yes, if my understanding of your requirement is correct. But you have to use Server-Side Processing with .NET for example.<br /><br />Using Client-Side Acrobat JavaScript ....!!!?? I am not sure, and my advise is to avoid this direction if you want to be able to sleep at night. JavaScript was designed to be so much secured, and once you want to perform any action (fully programmable) outside the boarders of the PDF Form, then you will face a path full of prickles.<br /><br />Using ASP/.NET it is very easy.<br /><br />When you submit (using Javascript Submit command I mentioned earlier in this thread) from PDF Client to ASP or ASPX Page on the server, the Request Object has everything you need in XML.<br /><br />All you need to do is to debug the application and set a break point after loading the XML Document form the Request Object Stream. When in debug mode, use the Autos watch window to view the XML content of the loaded XML Document.<br /><br />Are you familiar with .NET XML APIs?<br /><br />Now, you need to use .NET APIs to parse the XML to extract the Parent Node you want. The proper way is to use XPath Query with the API to select a single node or something like that.<br /><br />For example, if the XML looks as follows:<br /><br /><parent><br /> <child1><br /> <child2><br /> <name>yyyy</name><br /> <age>12</age><br /> </child2><br /> <child2><br /> <name>xxxx</name><br /> <age>14</age><br /> </child2><br /> </chile1><br /></parent><br /><br />Then id XPath is "/parent/child1" then the Result Node will start with <child1> and all it children nodes.<br /><br />Let me know if you still need help.<br /><br />Tarek.

Avatar

Former Community Member
I am not quite sure we are talking about the same thing but maybe we are?

Are you saying I should work on creating an .NET aspx page that uses an XML API that reads the XML data from my PDF file?

I think I understand that part but does the XML API create an .XML file on the server?

Avatar

Level 8
Yes, absolutely !



Check the documentation of XMLDocument .NET Class ... it has everything you need.



You have to load the XML from the Response Input Stream to XMLDocument object, and extract the required XML Node into another XMLDocument Object, then you have to export the content of this Node into a File using some kind of Stream Writer. From XMLDocument class, I think there is some method that exports to XML Text file directly.



Tarek.

Avatar

Former Community Member
Thanks for the help. I have been doing a lot of research on this and been going nuts because they dont show any examples other than reading from a specific xml from a specific location such as "(Server.MapPath("MySource.xml"));" however, this is not true for a PDF file that is sending the data to an web page - I reviewed your code that you posted but havent been able to decifer how you are doing it. Are you using a specific file from a specific location? in your web code are you using loadXML("filename") because I cant get load(Request) to work...



again, thanks for your help on this, I have made some progress but not all the way there yet.

Avatar

Level 8
The following sample code (which I copied from the code I posted earlier), will be the starting point to Extract the XML Node you want, but you have to know the name of the Node, which you can find out by debugging the code:

---

Dim sreader As New System.IO.StreamReader( Page.Request.InputStream)

Dim xmlData As String = sreader.ReadToEnd()

Dim xmldoc As New System.Xml.XmlDataDocument

Dim SubmittedFormPart As String



xmldoc.LoadXml(xmlData)



Session("StaffName") = xmldoc.GetElementsByTagName("Name")(0).InnerText

Session("StaffID") = xmldoc.GetElementsByTagName("StaffID")(0).InnerText

---



Note this part "Page.Request.InputStream". This is the source of Data which was submitted by the PDF Form from the Client to the Server. It has EVERYTHING, so you need to determine what you are looking for.



So the code above will convert Page.Request.InputStream into "xmldoc", then you need to watch the value of xmlDoc while debugging.



The "GetElementsByTagName" is a method of the class "XMLDataDocument". You need to lookup the documentation if this class to "figure out" how to extract the "Node" you want (GetSingleNode I think !), convert it to String, and write it to a file. I think you need a Stream Writer, if this cannot be done directly by the XMLDataDocument methods.



Tarek.

Avatar

Former Community Member
I was able to get it to work, here is a part of my code (this is an .asp page):
<br />
<br /><%@Language="VBScript"%>
<br /><%Option Explicit%>
<br /><%Response.Buffer = True%>
<br />
<br /><%<br /><br /> Dim xml<br /> Dim fullpath<br /> Dim dynamicName<br /> Dim infoRFC<br /> Dim infoDate<br /> Dim infoRequestor<br /> Dim infoLocation<br /> Dim infoProject<br /> Dim infoProjectDate<br /><br /> <br />' start the XML object<br /> Set xml = Server.CreateObject("Microsoft.XMLDOM")<br /> <br />'wait for the xml to be read<br /> xml.async = False<br /> <br />'load data transmitted from the PDF form to the web page<br /> xml.load (Request)<br /><br /> <br />'collect information from XML fields<br />infoRFC = xml.GetElementsByTagName("main")(0).text<br />infoRequestor = xml.GetElementsByTagName("Requestor")(0).text<br />infoDate = xml.GetElementsByTagName("input_date")(0).text<br />infoLocation = xml.GetElementsByTagName("Location")(0).text<br />infoProject = xml.GetElementsByTagName("project_name")(0).text<br />infoProjectDate = xml.GetElementsByTagName("AOSDate")(0).text<br /><br /> <br /> <br />'write information to the web page<br />Response.Write(infoRFC + " Submitted!")<br />Response.Write("Requestor: " + infoRequestor)<br />Response.Write("Date: " + infoDate)<br />Response.Write("Location: " + infoLocation)<br />Response.Write("Project: " + infoProject)<br />Response.Write("Project Date: " + infoProjectDate)<br /> <br /> <br /> <br />'save the loaded xml file to a specific location on the server<br />xml.save(Server.MapPath(infoRFC+".xml"))<br /> <br />fullpath = Server.MapPath(infoRFC + ".xml")<br /> <br />dynamicName = (infoRFC+".xml")<br /> <br />response.write("File Name: " + dynamicName)<br /><br />%>

Avatar

Former Community Member
This thread is very valuable and full of information.



Tarek Adnan Faham - I have one confusion that I want to ask.



From client viewing of PDF than submitting it to asp and saving to database, where we need Adobe Acrobat 8 Professional? . Client who is filling the pdf and submitting don't need Adobe Acrobat 8 Professional on his machine right? acrobat reader 8 will able him to fill the PDF and submit it to aspx page.



Thanks

Avatar

Level 8
Pirzada ,



I think if the client does not have full version of Adobe Acrobat, then some of the functions will not work, for example, you will not be able to submit the Fill PDF as Binary with Signatures to the Server.



I think if you only want to submit the Form Field Values, then Adobe Reader is enough, but I will not bet my life on this.



Regards ...



Tarek.

Avatar

Former Community Member
Thanks for the quick reply.



I think that suppose I have website that is immigration related and I have PDF that needs to be filled by user than I am sure he won't buy full version of Acrobat as most of them have Acrobat reader.



I wanted the user to fill in the PDF data and send it to apx page where I be able to save it in database. Thats what I intend to do. What do you suggest?



Thanks

Avatar

Former Community Member

Do you need to parse the XDP, FDF, XFDF, or XML field name/values into a database using ASP.net?

Check out http://www.fdftoolkit.net/ by NK-Inc.com

NK-Inc.com's FDFToolkit.net's syntax is very much like the Adobe's FDF Toolkit, except, NK-Inc.com works on local, remote servers and workstations, and it is created for ASP.net, C#, and VB.net.

FDFToolkit.net can parse, populate, import, export, create, and modify XDP, XML, FDF, XFDF.

If the PDF field names match the database field names, FDFToolkit.net can even populate an ADO.net dataset or datarow.

Not only does NK-Inc.com's FDFToolkit.net parse form data, it can merge the data back with LiveCycle or Acrobat PDF forms, and even flatten the forms.

NK-Inc.com's FDFToolkit.net utilizes iTextSharp technologies.

NK-Inc.com's FDFToolkit.net

http://www.fdftoolkit.net/

*Includes 1 year of technical support and updates.

Avatar

Level 8

Does FDFToolkit supports Dynamic PDF Forms (XFA) ?

Tarek.

Avatar

Former Community Member

FDFToolkit.net supports Static XFA LiveCycle forms and PDF forms created with Adobe Acrobat.

Dynamic forms are a limitation set by iTextSharp and/or Adobe.

Other limitations include, "normal" bindings, and limitations with Extended Usage Rights for Reader.