Image Field Z-Order Problems

h2. Description

If you’ve ever tried to use an image field’s contents (an image) as the background for a form and wanted to let the user change it at run-time, you’ve probably run into problems if you had placed objects on top of this image field. The most common result is the image field’s contents always appears on top of all other fields which are technically higher in z-order (“in front” in the hierarchy) than the image field.

While this may seem like buggy behaviour, it’s not technically a bug and I’ll try to explain why it isn’t.

The behavior occurs because of the way image fields are translated from XFA objects to “AcroForm objects”:http://blogs.adobe.com/formbuilder/2006/06/acroform_objects.html when your form is saved as a PDF and rendered in Acrobat.

The PDF format has a definition for what is called an _Annotation_ object which represents essentially all the “extra” stuff you can add to PDF documents such as comments, stamps, highlighting, etc. When it comes to image fields, their contents is actually an Annotation in the PDF layer as opposed to contents in the XFA layer. Since the PDF layer is above the XFA layer, Annotations can’t be placed behind objects on the XFA layer — hence why the contents of an image field is always displayed above any objects that may be “in front” of it in the XFA hierarchy (z-order).


h2. WorkaroundUnfortunately, there aren’t any workarounds to this problem if you want users to pick the image field’s contents at run-time (in Acrobat) or if you specifically need to use an image _field_ object.If you are able to restrict the possibilities to a known set of images that you can store in the form at design-time (in Designer), however, then you could embed all the images in separate read-only image objects (note that this is a _static_ image object — not an image _field_ object) and then change their presence attribute (make one visible and all the others invisible) when the user performs an action that would’ve let them change the background image.Since _static_ image objects (as opposed to image _field_ objects) render their contents in the XFA layer at the moment the form is rendered in Acrobat, their contents appears “behind” all the other objects, as is desired in this case.h2. FixPlease refer to the “Bug List”:http://blogs.adobe.com/formbuilder/buglist.html for updated information on the version(s) affected by this bug as well as if and when it was/will be fixed.