Populate PDF form with XML data | Community
Skip to main content
April 12, 2005

Populate PDF form with XML data

  • April 12, 2005
  • 38 replies
  • 12535 views
Although a seemingly simple task, this question has occupied way too much of my time the last week and I am asking the following out of sheer desperation and frustration.



I have a pdf form created with Designer 7.0. I have a separate XML data file to populate the form with. I can test using the preview in Designer and everything looks great. Now, all I want to do is deploy this pdf to a standard web server (IIS, Windows) such that any visitor to the site (using Reader) is able to open it/view it/print it, with the data there. That's it.



This was easily accomplished using Acrobat 6 by creating an ASP page that output an FDF file which referenced the PDF. Not so with the latest version.



I have downloaded three separate several hundred page documents that do not explain how to accomplish this task simply. So to summarize:



1. Does this task *require* a separate piece of software (Document Server) that was not required before?

2. If Document Server is not required, what are the steps to publish the pdf file and reference the data file?



Please help, extraordinarily frustrated :-(.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

38 replies

November 4, 2005
Hi,<br />i've got similar problem, here is my php code:<br /><br /><?php<br />header("Content-Type='application/vnd.adobe.xdp+xml'");<br />echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";<br />echo "<?xfa generator=\"AdobeDesigner_V7.0\" APIVersion=\"2.2.4333.0\"?>";<br />echo "<xdp:xdp xmlns:xdp=\"http://ns.adobe.com/xdp/\">";<br />echo "<xfa:datasets xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\">";<br />echo "<xfa:data>";<br />echo "<TSP301>";<br />echo " < form > ";<br />echo " < text > sampletext < /text > ";<br />echo "< /form >";<br />echo "</TSP301>";<br />echo "</xfa:data>";<br />echo "</xfa:datasets>";<br />echo "<pdf href=\"http://mercury:8080/sample/dane.pdf\" xmlns=\"http://ns.adobe.com/xdp/pdf/\" />";<br />echo "<xfdf xmlns=\"http://ns.adobe.com/xfdf/\" xml:space=\"preserve\" >";<br />echo "<annots/>";<br />echo "</xfdf>";<br />echo "</xdp:xdp>";<br />?><br /><br />also, i've got simplest pdf on the server (Apache 2) with only one text field, and the all i get in firefox or ie is:<br /><br />sampletext<br /><br />it's only a text, it do not open pdf and load it with data but when i get the source of the page i see all this data wich i 'echo' from php script<br /><br />where i make mistake, maybe someone can show me working php code to preload pdf with data<br /><br />£ukasz
November 11, 2005
hi

I have a Web Page With PDF and asp, and write same example of here but

The asp page brings up the pdf file but the data does not seem to load

The file xdp is good, but not load in my Web PDF when use my asp



Why that problem?



Thanks for your help
December 15, 2005
Guys:<br />HEre is the code snippet that works. I tried it with ASP.NET and with Acroba Professional 7.0 installed on the local box.<br /> public class WebForm1 : System.Web.UI.Page<br /> {<br /> private void Page_Load(object sender, System.EventArgs e)<br /> {<br /> string temp = "";<br /><br /> StringBuilder responseString = new StringBuilder();<br /> Response.ContentType = "application/vnd.adobe.xdp+xml";<br /> responseString.Append( "<?xml version='1.0' encoding='UTF-8'?>");<br /> responseString.Append("<?xfa generator='AdobeDesigner_V7.0' APIVersion='2.2.4333.0'?>");<br /> responseString.Append("<xdp:xdp xmlns:xdp='http://ns.adobe.com/xdp/'>");<br /> responseString.Append("<xfa:datasets xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/'>");<br /> responseString.Append("<xfa:data xfa:dataNode='dataGroup'>");<br /> StreamReader sr = File.OpenText("c:\\inetpub\\wwwroot\\CaptureAcrobat\\PersonalInfo_data.xml");<br /> string xmldata = sr.ReadToEnd();<br /> sr.Close();<br /> responseString.Append(xmldata);<br /> responseString.Append("</xfa:data>");<br /> responseString.Append("</xfa:datasets>");<br /> responseString.Append("<pdf href='http://localhost/CaptureAcrobat/PersonalInfo.pdf' xmlns='http://ns.adobe.com/xdp/pdf/' />");<br /> responseString.Append("<xfdf xmlns='http://ns.adobe.com/xfdf/' xml:space='preserve'>");<br /> responseString.Append("<annots/>");<br /> responseString.Append("</xfdf>");<br /> responseString.Append("</xdp:xdp>"); <br /><br /> Response.Write(responseString);<br /> Response.Flush();<br /> Response.End();<br /> }<br /><br />}
December 22, 2005
lakshmin Ramakrishnan,



Could you help me a little here? I followed your Dot.NET code. Also created PDF and xml files. However, when I viewed the aspx file, I got some xml parse error message and did't see the pdf either.



I must missed something. Your help will be very appreciated!!!

Thanks in advance.

Jie
January 14, 2006
I could not agree more! I have been so frustrated just tring to populate a PDF with XML, what should be a simple thing.... I also am having trouble with the example code from post 22. Any additional advise may end my suffering! Thanks much, Brian
February 16, 2006
I did exactly what you did.

Borwser is loading with the appropriate PDF but not with the values.

Could you please send working copy to me.

Thanks again.
February 16, 2006
I am hoping to figure this one out eventually. I wish they had an example that walked you through whole process.<br /><br />I created the following code. My form appears without the field being populated also. I went into designer pull up the pdf added some data and tried to export the data as xml and xdp. The xml shows with no data. Tried to open xdp its say unable to locate template. <br /><br />Is this xml correct? (this is being used in designer to perform the <br />binding <br /><?xml version="1.0" encoding="UTF-8"?> <br /><TextField1><value>Howard</value></TextField1> <br /><br />After I have binded the field <br /><br />I use the following asp to display the pdf with <br />the one field filled in. <br /><br />Is this xml correct? <br /><br /><% Response.ContentType = "application/vnd.adobe.xdp+xml" response.write "<?xml version='1.0' encoding='UTF-8'?>" <br />response.write "<?xfa generator='AdobeDesigner_V7.0' APIVersion='2.2.4333.0'?>" <br />response.write "<xdp:xdp xmlns:xdp='http://ns.adobe.com/xdp/'>" <br />response.write "<xfa:datasets xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/'>" <br />response.write "<xfa:data xfa:dataNode='dataGroup'>" <br />response.write "<TextField1><value>Howard</value></TextField1>" <br />response.write "</xfa:data>" <br />response.write "</xfa:datasets>" <br />response.write "<pdf href='http://159.83.96.138/prod/myFirstShot.pdf' xmlns='http://ns.adobe.com/xdp/pdf/' />" <br />response.write "<xfdf xmlns='http://ns.adobe.com/xfdf/' xml:space='preserve'>" <br />response.write "<annots/>" <br />response.write "</xfdf>" <br />response.write "</xdp:xdp>" <br />Response.Flush <br />Response.End <br /><br />%>
April 10, 2006
Garth,

In step 2 of your resolution, you mentioned to use data binding feature.

I want to know... is it (the data connection part) to be done just for testing purpose or whether it has any significance in actually generating dynamic PDF.



I am asking this question, 'cause in my case, I do not have separate XML data file. I am creating XML name value pairs in code and included that in XDP code.



Another question. What should be the "Return Method" be set to, when creating PDF form.

Fill then Submit (OR) Fill the Submit/Print (OR) Fill then Print (OR) Print



My requirement is same as yours except for XML data file which I mentioned above.



Any pointers would be of great help.



Thanks
April 12, 2006
This has been an EXTREMELY helpful thread. I was able to get this concept working. Does anyone know if its possible to force this file to save as a PDF rather than prompting the user to open or save?
April 12, 2006
I should have included in my message that I understand that it could not automatically save on the client (as this would be a big security no-no) -- I'm looking to then save it on the server.