I am trying to dynamically change the logo on an adobe form using XML data binding. That is, if my XDP form has an ImageField like the following, I would like to pass in various values (ex. logo1.jpg, logo2.jpg) for the 'href' attribute on the 'image' element.
We have been successfully binding simple text fields for a while now. I would like to be able to use the same approach to swap in the various logos. Here's a brief overview of how we are currently using XML data binding.
* XML schema snippets (defines some phone number info):
We tried this approach before posting our initial question, but were unable to get it working. It may just be that my limited XSD and namespace knowledge is preventing me from getting it right, and that I need an example to work off of.
We are generating the XSD from an example instance XML, and then using JAXB to generate classes based on the resulting schema. These generated classes are used to populate the XML that will eventually be bound to the XDP to produce a PDF.
I think one of our main hurdles is the fact that we can't find the XFA XSD online anywhere. Do you have a copy of it?
Anyway, if it's not too much of an inconvenience, could you please post an example XDP snippet that you are using to bind an image with. I would imagine that it is a 'field' element with a nested 'image' element that has 'href' and 'contentType' attributes, but I would like to confirm this.
Also, could you please post more context for the 'imageData' element in the XSD, so that I can compare it to my solution. More specifically, I guess I'm looking for the XSD snippet showing an element containing an 'imageData' element. The only other thing I can think of that I might be doing wrong in the XSD, is the XFA namespace and XSD import/include, so an example of that would be much appreciated as well.
Thank-you for taking the time to respond to my original post.
Diana,<br /> Try this out. Cut and paste the following schema into a text file and save it with a .xsd file <br />extension:<br /><br /><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" <br />xmlns:xfadata="http://www.xfa.org/schema/xfa-data/1.0/"><br /> <xsd:element name="rootNode"><br /> <xsd:complexType><br /> <xsd:sequence><br /> <xsd:element name="imageData" maxOccurs="unbounded"><br /> <xsd:complexType><br /> <xsd:attribute ref="xfadata:contentType" default="image/" /><br /> <xsd:attribute ref="xfadata:href" /><br /> </xsd:complexType><br /> </xsd:element><br /> </xsd:sequence><br /> </xsd:complexType><br /> </xsd:element><br /></xsd:schema><br /><br />Now cut and paste the following XML into a text file and save it with a .xml file extension:<br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><rootNode><br /> <imageData contentType="image/jpg" href="http://www.google.com/intl/en/images/logo.gif"/><br /></rootNode><br /><br />Next, create a brand new, blank form in Designer.<br />Go to your Data View tab and select "New Data Connection".<br />Select 'XML Schema' and click 'Next'.<br />Select the .xsd file you created and click 'Finish'.<br />You should now see an 'imageData' node in your data view. It should have the same icon as the <br />'Image Field' object in the library. Because of the way the schema was defined, Designer <br />automatically identifies this as an image field.<br />Drag and drop the 'imageData' node onto your form. This will automatically create an image field <br />and bind it to your schema.<br />Select 'Form Properties' from the File menu, go to the 'Defaults' tab and select the .xml file you <br />created above as the preview data file.<br />Click on the 'PDF Preview' tab to merge the xml data with the xdp form and render it as PDF. You <br />should see the google logo on the page.<br /><br />Let me know if this works for you.<br /><br />-- <br />Justin Klei<br />Cardinal Solutions Group<br />www.cardinalsolutions.com
I apologize for not getting back to you sooner. I was very pregnant when I started this thread, and have since given birth to healthy baby boy and am on maternity leave.
Thank-you again for taking the time to look into this. With your help, we did finally have the eureka moment when Designer automatically identified it as an image field and changed the icon accordingly.
I found this post about dynamic image loading and i was able to follow the instructions given above. I was able to load the image dynamically in the LiveCycle designer however, when I try publishing the pdf and opening it, I the image does not load properly. Am I doing something incorrectly when I publish the pdf file?