ASP.NET: Populate PDF with XDP

576 views
Skip to first unread message

tyhugh2

unread,
Jan 14, 2008, 12:58:20 PM1/14/08
to Adobe LiveCycle Developers
I have the following code to populate my PDF with data. Here is the
specs on my PDF doc.

Created With: Adobe Livecycle Designer 8.0
Form Format: Acrobat 8 Dynamic XML Form

When I run this code, the pdf doesnt open at all. Can someone please
help. Thanks in advance!

StringBuilder XDFdataset = new StringBuilder();
XDFdataset.Append(@"<?xml version='1.0' encoding='UTF-8'?>");
XDFdataset.Append(@"<?xfa generator='XFA2_4'
APIVersion='2.6.7120.0'?>");
XDFdataset.Append(@"<xdp:xdp xmlns:xdp='http://ns.adboe.com/
xdp/'>");
XDFdataset.Append(@"<xfa:datasets xmlns:xfa='http://
www.xfa.org/schema/xfa-data/1.0/'>");
XDFdataset.Append(@"<xfa:data>");
XDFdataset.Append(@"<form1>");
XDFdataset.Append(@"<mySubForm>");

XDFdataset.Append(@"<TextField1>");
XDFdataset.Append(@"Test");
XDFdataset.Append(@"</TextField1>");

XDFdataset.Append(@"<TextField2>");
XDFdataset.Append(@"Test");
XDFdataset.Append(@"</TextField2>");

XDFdataset.Append(@"<TextField3>");
XDFdataset.Append(@"Test");
XDFdataset.Append(@"</TextField3>");


XDFdataset.Append(@"</mySubForm>");
XDFdataset.Append(@"</form1>");
XDFdataset.Append(@"</xfa:data>");
XDFdataset.Append(@"</xfa:datasets>");
XDFdataset.Append(@"<pdf href='http://localhost/oetest/b.pdf'
xmlns='http://ns.adobe.com/xdp/pdf/'/>");
XDFdataset.Append(@"<xfdf xmlns='http://ns.adobe.com/xfdf/'
xml:space='preserve'>");
XDFdataset.Append(@"<annots/>");
XDFdataset.Append(@"</xfdf>");
XDFdataset.Append(@"</xdp:xdp>");


Response.ContentType = "application/vnd.adobe.xdp+xml";
Response.Write(XDFdataset);
Response.Flush();
Response.End();

Duane Nickull

unread,
Jan 15, 2008, 11:45:00 AM1/15/08
to Adobe LiveCycle Developers
You seem to be creating a valid XDP document (caveat: I haven't checked the
result) but are not issuing any explicit instructions that will open up the
document once created in memory. You need a XDFdataset.Open() type
statement that the environment will interpret that you want to create the
document and open it. You could also potentially save the document to a
persistent place on the filesystem then open it. Or have you tried that?
Can you share more on the architecture of your overall application needs?

Duane Nickull

--
**********************************************************************
"Speaking only for myself"
Senior Technical Evangelist - Adobe Systems, Inc.
Blog - http://technoracle.blogspot.com
Community Music - http://www.mix2r.com
My Band - http://www.myspace.com/22ndcentury
Adobe MAX 2008 - http://technoracle.blogspot.com/2007/08/adobe-max-2008.html
**********************************************************************

tyhugh2

unread,
Jan 15, 2008, 12:42:17 PM1/15/08
to Adobe LiveCycle Developers
Yes

Server: IIS 5.0
.NET Framework 3.5 - 2.0 can be used

Initially I used a HTTP handler to process the request, however for
testing purposes i am using a standard aspx page with the code behind
model. After further reseach, I added uuid and timestamp attributes to
the <xdp> element (<xdp:xdp xmlns:xdp='http://ns.adboe.com/xdp/'
timeStamp='2008-01-15T14:58:18Z' uuid='28dc58ea-57fd-4e7b-
ab8d-1fa67a9a2872'>). So now im getting the following message

"Unable to locate the form, because the XFA data lacks a reference to
the PDF document. If the data came back as a result of a submit from a
PDF, then the URL is probably missing "#FDF" at the end."

I tried different URI's using the file system and HTTP, but still no
cigar.

Below is a copy of the entire method.


protected void Page_Load(object sender, EventArgs e)
{
StringBuilder XDFdataset = new StringBuilder();
XDFdataset.Append(@"<?xml version='1.0' encoding='UTF-8'?>");
XDFdataset.Append(@"<?xfa
generator='AdobeLiveCycleDesigner_V8.0' APIVersion='2.5.6290.0'?>");
XDFdataset.Append(@"<xdp:xdp xmlns:xdp='http://ns.adboe.com/
xdp/' timeStamp='2008-01-15T14:58:18Z' uuid='28dc58ea-57fd-4e7b-
ab8d-1fa67a9a2872'>");

XDFdataset.Append(@"<xfa:datasets xmlns:xfa='http://
www.xfa.org/schema/xfa-data/1.0/'>");
XDFdataset.Append(@"<xfa:data xfa:dataNode='dataGroup'>");
Thanks for responding! I hope that we or someone can get to the bottom
of this, as I am three days in.

Dave Venance

unread,
Jan 17, 2008, 7:30:14 PM1/17/08
to Adobe LiveCycle Developers
Ok, I don't know if this is a result of the editor here on the forums,
but when I took the data from your code above, everywhere that there
was a line break, there was some missing white space that the system
requires. For example, near the beginning of the XDP file, you have a
tag like <?xfa generator...>. There needs to be a space between xfa
and generator, and in the file above, there didn't appear to be one.
The same thing for the pdf href line, there was no space between the
name of the pdf and the xmlns parameter.

In order to see what a valid XDP should look like, on your form, put a
button on it and make it a submit button and on the submit URL, to
mailto:// and some email address. Then test your form in the Designer
and click the button. It should open your mail client and attach an
XDP that you can look at to see what the format should be.

On Jan 15, 1:42 pm, tyhugh2 <th...@mednethealth.net> wrote:
> Yes
>
> Server: IIS 5.0
> .NET Framework 3.5 - 2.0 can be used
>
> Initially I used a HTTP handler to process the request, however for
> testing purposes i am using a standard aspx page with the code behind
> model. After further reseach, I added uuid and timestamp attributes to
> the <xdp> element (<xdp:xdp xmlns:xdp='http://ns.adboe.com/xdp/'
> timeStamp='2008-01-15T14:58:18Z' uuid='28dc58ea-57fd-4e7b-
> ab8d-1fa67a9a2872'>). So now im getting the following message
>
> "Unable to locate the form, because the XFA data lacks a reference to
> the PDF document. If the data came back as a result of a submit from a
> PDF, then the URL is probably missing "#FDF" at the end."
>
> I tried different URI's using the file system and HTTP, but still no
> cigar.
>
> Below is a copy of the entire method.
>
> protected void Page_Load(object sender, EventArgs e)
> {
> StringBuilder XDFdataset = new StringBuilder();
> XDFdataset.Append(@"<?xml version='1.0' encoding='UTF-8'?>");
> XDFdataset.Append(@"<?xfa
> generator='AdobeLiveCycleDesigner_V8.0' APIVersion='2.5.6290.0'?>");
> XDFdataset.Append(@"<xdp:xdp xmlns:xdp='http://ns.adboe.com/
> xdp/' timeStamp='2008-01-15T14:58:18Z' uuid='28dc58ea-57fd-4e7b-
> ab8d-1fa67a9a2872'>");
>
> XDFdataset.Append(@"<xfa:datasets xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/'>");

tyhugh2

unread,
Jan 22, 2008, 11:34:55 AM1/22/08
to Adobe LiveCycle Developers
Thanks,

I actually setup my livecycle form to submit a XDP to my aspx page,
therefore i used the same formating and syntax. It still says

"Unable to locate the form, because the XFA data lacks a reference
to
the PDF document. If the data came back as a result of a submit from
a
PDF, then the URL is probably missing "#FDF" at the end."

I really believe that this works, but obviously there is something
that I am doing wrong. Below is a copy of my method. Dave Venance: Yes
I do have a space between xfa and generator in my code, and I just
wanted to tell you thanks for replying.......I have been on this issue
for about 3 weeks now.


protected void Page_Load(object sender, EventArgs e)
{
StringBuilder XDFdataset = new StringBuilder();
XDFdataset.Append(@"<?xml version='1.0' encoding='UTF-8'?>");
XDFdataset.Append(@"<?xfa
generator='AdobeLiveCycleDesigner_V8.0' APIVersion='2.5.6290.0'?>");
XDFdataset.Append(@"<xdp:xdp xmlns:xdp='http://ns.adboe.com/
xdp/' timeStamp='2008-01-15T14:58:18Z' uuid='28dc58ea-57fd-4e7b-
ab8d-1fa67a9a2872'>");

XDFdataset.Append(@"<xfa:datasets xmlns:xfa='http://
www.xfa.org/schema/xfa-data/1.0/'>");
XDFdataset.Append(@"<xfa:data>");
XDFdataset.Append(@"<form1>");
XDFdataset.Append(@"<mySubForm>");
XDFdataset.Append(@"<TextField1>");
XDFdataset.Append(@"Tyree Test");
XDFdataset.Append(@"</TextField1>");

XDFdataset.Append(@"<TextField2>");
XDFdataset.Append(@"Tyree Test");
XDFdataset.Append(@"</TextField2>");

XDFdataset.Append(@"<TextField3>");
XDFdataset.Append(@"Tyree Test");

Dave Venance

unread,
Jan 22, 2008, 8:39:55 PM1/22/08
to Adobe LiveCycle Developers
What I did was put a button on the form and make it a submit button
and then put a mailto: link in the URL and told it to submit the XDP
with nothing other than a data node. This gave me the exact XDP file
that I would need. I put the form on my web server and filled it out
and then clicked the button. This gave me a data file that looked
pretty much like what you have above. If I placed this XDP on my web
server and clicked it, I did not get the form either but I was not
getting the error you described. The error you have is because the
client cannot find the form where it is being referenced for some
reason. It should cause the client to retrieve the file on your
server (http://localhost/oetest/b.pdf) but it can't find it there.
Try adding the button and fill out the form to get a data file to make
sure it really looks like what you are generating.

The other thing that may be causing some issue is that I am not 100%
sure if you can use the free Adobe Reader to do this or if you need to
have Acrobat to do this. Typically to load (import) data into a form,
you would need Acrobat or an Reader Extended PDF. Are you using
Acrobat on your desktop?

On Jan 22, 11:34 am, tyhugh2 <th...@mednethealth.net> wrote:
> Thanks,
>
> I actually setup my livecycle form to submit a XDP to my aspx page,
> therefore i used the same formating and syntax. It still says
>
> "Unable to locate the form, because the XFA data lacks a reference
> to
> the PDF document. If the data came back as a result of a submit from
> a
> PDF, then the URL is probably missing "#FDF" at the end."
>
> I really believe that this works, but obviously there is something
> that I am doing wrong. Below is a copy of my method. Dave Venance: Yes
> I do have a space between xfa and generator in my code, and I just
> wanted to tell you thanks for replying.......I have been on this issue
> for about 3 weeks now.
>
> protected void Page_Load(object sender, EventArgs e)
> {
> StringBuilder XDFdataset = new StringBuilder();
> XDFdataset.Append(@"<?xml version='1.0' encoding='UTF-8'?>");
> XDFdataset.Append(@"<?xfa
> generator='AdobeLiveCycleDesigner_V8.0' APIVersion='2.5.6290.0'?>");
> XDFdataset.Append(@"<xdp:xdp xmlns:xdp='http://ns.adboe.com/
> xdp/' timeStamp='2008-01-15T14:58:18Z' uuid='28dc58ea-57fd-4e7b-
> ab8d-1fa67a9a2872'>");
>
> XDFdataset.Append(@"<xfa:datasets xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/'>");
Reply all
Reply to author
Forward
0 new messages