Expand my Community achievements bar.

Correct way of serving from web server, prepopulating fields?

Avatar

Former Community Member
This is what I need to accomplish: Display a PDF prepopulated with existing information from a database in a browser, accept a HTTP submit back, and update the database accordingly.<br /><br />While experimenting, I managed to create a form in Designer, render a PDF, open it in Acrobat, enter some data, export the data as XDP. I put the PDF on a web server, took the contents of the XDP and updated the href link to point to the PDF of the web server, and made an ASP page that dumps the XDP out with the ContentType header set as shown below. It seems to work. Is this a reasonable approach? What is the "correct" way of doing this? The "old" way with regular AcroForms was to use FDF. I've seen that there is something called XFDF. How does XFDF relate to XDP and XFA, and does it apply in this scenario?<br /><br /><% Response.ContentType = "application/vnd.adobe.xdp+xml" %><?xml <br />version="1.0" encoding="UTF-8"?><br /><?xfa generator="XFA2_0" APIVersion="2.2.4333.0"?><br /><xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"><br /><xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"<br />><xfa:data<br />><form1<br />><TextField1<br />>marcus</TextField1<br />></form1<br />></xfa:data<br />></xfa:datasets<br />><br /><pdf href="http://localhost/testform.pdf" <br />xmlns="http://ns.adobe.com/xdp/pdf/"<br />/></xdp:xdp><br /><br />Also, if possible, it would be nice to be able to dynamically populate combo boxes with options etc in the form from the database. If I save a Designer form as XDP it's easy to do this and other form modifications, since it's plain XML. However, I would need to be able to render the form into PDF to be able to display it in Acrobat Reader, right? Is this possible without buying super expensive sever software from Adobe?
9 Replies

Avatar

Former Community Member
Hi

I have done this. Not with XDP but an ordinary submit.

Have a look at http://www.dtp-tjanst.com/Acrobat/PreLoad/PreLoad3.pdf

It is in Swedish but I believe that you understand any how.

You can assign a "Ärendenummer" (Matter) sentence, a name and a text.

Use "Spara" to Save and then "Radera Data" to Erase the data.

Retype the "Ärendenummer" (Matter) and click "Hämta" to Reload the data from the server.

All done in ASP.NET

You can do it all from Acrobat Reader.

/Ulf

Avatar

Former Community Member
Thanks Ulf! Nice demo! Yep, that's pretty much what I want to do. The Swedish wasn't a problem, because I'm Swedish too. ;)



I also figured out how to prepopulate comboboxes with the options to choose from, thanks to another thread on here.



Ha det bra!

Avatar

Former Community Member
Lumbus,



I am looking for a way to pre-populate the dropdownbox. Can you shed some light on how to pre-populate the dropdownbox with data from database?



Thanks.

Avatar

Former Community Member
The last post in this thread was enough to figure it out for me:
Ian Schmidt, "How To: Populuate Drop-Down List via XDP" #6, 19 Oct 2005 3:10 pm



Additional explanations:

If I have a form called form1, I can insert my data for the dropdown inside the form1 node in the xfa:data node of the XDP. If this data node is called "names", the path to use with xfa.resolveNode would be "xfa.datasets.data.form1.names" (I think this was a small error in the post I linked to above).

Avatar

Former Community Member
So in order for the javascript in that post to work, I need to have a DSN setup on my system called "names" ?



I want my server side ASP script to populate the listbox without having to create local DSN. Is it possible?

If it is, can you give me an example of how the XML data stream would look like for the within the xfa:datasets tag?

Avatar

Former Community Member
No, no DSN needed. You just need to decorate XDP XML tree that you send back to the browser a little. For example, with the example above, the xfa section in the XDP would look something like:<br /><br /><xfa:data><br /> <form1><br /> <names><br /> <name ORG_NAME="name1" ORG_ID="id1"></name><br /> <name ORG_NAME="name2" ORG_ID="id2"></name><br /> </names>

Avatar

Former Community Member
Below is the script on the form:ready event of my droplist:<br /><br />var objDataGroup = xfa.resolveNode("xfa.datasets.data.form1.IDs"); <br /><br />if (objDataGroup != null) <br />{ <br /> var nLength = objDataGroup.nodes.length; <br /><br /> for (var i = 0; i < nLength; ++i) <br /><br /> { <br /> var valName = objDataGroup.nodes.item(i).IDItem.value; <br /> var valID = objDataGroup.nodes.item(i).bFirstName.value; <br /> if ((valName != null) && (valID != null))<br /> {<br /> this.addItem(valName, valID); <br /> } <br /> } <br />}<br /><br />And this is what my ASP script generated. <br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><?xfa generator="XFA2_0" APIVersion="2.2.5028.0"?><xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"><br /><xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><br /><xfa:data><br /><form1><br /><IDs><br /><ID IDItem=15 bFirstName=John></ID><br /><ID IDItem=16 bFirstName=John></ID><br /><ID IDItem=17 bFirstName=John></ID><br /><ID IDItem=18 bFirstName=John2></ID><br /><ID IDItem=19 bFirstName=></ID><br /><ID IDItem=1 bFirstName=John></ID><br /><ID IDItem=11 bFirstName=John></ID><br /><ID IDItem=12 bFirstName=john></ID><br /><ID IDItem=13 bFirstName=Ken></ID><br /><ID IDItem=14 bFirstName=John></ID><br /></IDs><br /></form1><br /></xfa:data><br /></xfa:datasets><br /><pdf href="http://localhost/popDDL.pdf" xmlns="http://ns.adobe.com/xdp/pdf/" /><br /></xdp:xdp><br /><br />But I still can not get the droplist to be populated. Can you tell me what is wrong?

Avatar

Former Community Member
Looks almost right, but a couple of things:



1. Check the braces. They don't seem to match up right.

2. The XML is invalid. You need quotes ("") around all attributes. bFirstName="John" etc...



If you still can't get it to work, try checking if it can find your IDs node. For example, you can write the value of nLength to a text field on the form (you'll probably want to initialize it to -1 or something before the if statement though).



Designer can tell you if your javascript syntax is correct.