Bug: Images aren't always embedded into PDFs
Description
Image objects (images and image fields) have a property which you can set to specify whether the image should be embedded or linked (the "Embed Image Data" check box on the Object palette’s Field tab).
When the property is checked, the result is that the image file loaded into the image object is embedded into the XFA Data that’s stored in the form. When the property is unchecked, only the URI (file path or URL) is stored in the XFA Data.
I put emphasis on XFA Data above because it’s important to understand the difference between the XFA layer and the PDF layer of a PDF form in order to understand what this bug is all about: Essentially, an XFA form saved as a PDF file results in a PDF container with the XFA inside (as opposed to saving the form as an XDP where the XFA form is at the top layer). When the PDF form is subsequently filled and saved within Acrobat (Standard or Pro), the image loaded into an image field object is supposed to be saved on one layer or the other depending on the setting of the "Embed Image Data" property on the image field.
When you save a PDF form in Acrobat, what gets saved in the XFA Data (in the XFA layer) depends on the value of the "Embed Image Data" property (which maps to the //field/ui/imageEdit@data attribute). If it’s set to "link" (unchecked), then only the original path to the image file is saved. If it’s set to "embed", then the image file is text-encoded and saved in the data instead of the original file path. In either case, however, the image should always be embedded into the PDF layer (don’t worry, it doesn’t actually get embedded twice, once on each layer, I’m just simplifying things a little here) such that the PDF is self-contained and can be re-distributed without having to ensure that the linked image file remains accessible from any location.
Unfortunately, there are cases when the image file doesn’t get embedded into the PDF layer when it should be. For example, if you have an image field object which is set to link to its image file and you load the image by importing data that contains the file path then save the PDF, the image won’t be embedded into the PDF as expected.
Workaround
At this time, I’m not aware of any workarounds to the specific issue I stated above (when importing the image’s file path).
The only way to consistently get image files to be embedded into the PDF as they should be — regardless of the image field object’s setting to link or embed its data — is to manually click on the image field object in Acrobat and pick the image file.
Fix
Please refer to the Bug List for updated information on the version(s) affected by this bug as well as if and when it was/will be fixed.
Update (May 22, 2008)
This bug was addressed in Acrobat/Reader 8.1 (XFA 2.6, PDF 1.7) in a way that addresses both security and PDF self-containment issues.
For XFA 2.6+ forms (forms authored in Designer 8.1+), images that are linked (referenced) rather than being embedded are now stored (the bits are embedded) in an array in the PDF layer when the PDF form is saved. At runtime, if an image is linked (referenced) rather than embedded, Acrobat/Reader will look for the associated image bits in the PDF layer and, if a match is found, will load the image. This means that Acrobat/Reader no longer goes outside of the PDF to fetch images unless explicitly directed by the user (e.g. the user clicks on an image field and chooses an image on their own) which addresses security issues. The fact that linked images are now stored in the PDF layer also addresses self-containment issues where the nature of a PDF document is that it is a self-contained entity (e.g. when you email a PDF, the recipient can always open it and see its content even if they don’t have access to referenced content — the exception being if the form makes an external data connection to a database or web service or needs an XML data file to be imported).
Image fields with content embedded at design time are still stored in the XFA data as they were before. You may still load an image dynamically from data provided that the data is the actual image bits or, if the data is a link, that there are associated image bits already in the PDF layer (which implies that the image was linked from the form at design-time — for example, you could have 5 hidden image objects each linking to different images and then use a link in the data to control which of those images show up in an image field on your form). In either case (whether the image is loaded via embedded bits or a link), the image bits always end-up in the data submitted from the form. The original link is not included in the submitted data nor is it available at runtime via scripting (unless imported in data via a data connection or XML data file) because it could contain sensitive information (e.g. your username).
Posted by Stefan Cameron on January 23rd, 2007
Filed under Acrobat,Bugs
Both comments and pings are currently closed.
Hi,
Are there any fixes to this bug yet?
Thanks,
Nolan
Nolan Smith,
Please see the May 22, 2008, update I just added to this post.
Hi,
I’ve been trying to pass a url to the pdf for the image but the pdf never loaded the image. According to your Description if I understood it correctly this is due to the need for the pdf to have the image embedded previously through using the designer.
Is there a way to allow the pdf reader to load an image from a link (href) without it having the image embedded ?
This is the the xfa that I am passing to the pdf :
echo ”;
echo ”;
echo ”;
echo ”;
echo ‘ ‘;
echo ‘
Hello Kris
— Over here I tried several other formats but none of them worked
href=”http://www.seriouswheels.com/pics-abc/Alfa-Romeo-8C-Competizione-sa-1600×1200.jpg”
‘;
echo ‘ ‘;
echo ”;
echo ”;
echo ”;
The text field worked fine … what i don’t understand is why the image field doesn’t load the new url …
Thanks in advance
Kristjan Farrugia,
I’m guessing you didn’t replace < characters with < in your comment…
In any case, an arbitrary image file for which the bits are not located either in the XFA or PDF layer, cannot be loaded programmatically. The only way to do it is to get the user to click on the image field and select the image.
The update on May 22 mentions “the exception being if the form makes an external data connection to a database or web service or needs an XML data file to be imported”
On March 24th you say “The only way to do it is to get the user to click on the image field and select the image.”
In your post at http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/
Someone asks if an image can be read from the database into an image field.
You reply “Theoretically, if your images were UTF-8 encoded and stored as text blobs in your database, you might be able to set the value of an image field to the value of the text blob by binding that column to the image field but I’ve never tried to do this in practice.”…
“ImageField1.value.resolveNode(“#image”).contentType = “image\\jpg”;”
Has anyone read an image from the database? Is there an example?
hi
I want to do dynamic image binding in the form, Which I were able to do in the form usign designer.
But when I generated the form using the service(renderPDFForm) it wasnt get bind.
To generate the above forms I am using the XSD(schema binding) having “image Data node” and xml file for genrating the PDF
plz see the below XML and XSD.
xsd is
xml is
@Akshat,
I’m not sure what you mean by “dynamic image binding” and your XSD/XML didn’t come across (you must not have replaced the < characters with < when you pasted then into the comment box). Nonetheless, I would need more specifics about what you’re trying to achieve rather than the entire schema and XML data.
@Stefan,
I have a different problem,but it seems the root is same.
I have a PDF with image in it. When I open it up in Acrobat Reader , i’m able to view the image. But, when I open the same in ADOBE LIVECYCLE DESIGNER, i’m unable to view the image.
Need help regarding this,
Acrobat Reader Version 8.2
ADOBE LCD Version 8.2
@Gaurav,
When you open the PDF in Designer, you’re not looking at any values that you may have set in any fields, you’re looking at the form’s design therefore the image wouldn’t show-up.
Furthermore, was this PDF originally designed in Adobe LiveCycle Designer?
The only way you would see an image in Designer is if (1) you created the form in Designer and (2) your form has a static image set to some picture or your form has an image field with a default picture assigned to it.
That being said, if you meant that you cannot see the image when you preview the PDF using Designer, this is yet another scenario. In this case, perhaps the form has an image field and you therefore need to provide a preview data file that contains information about the image to display in the image field.