by John Brinkman
Hey, it has been a while since I wrote a blog entry. I just spent a week visiting a customer site and getting familiar with a major form deployment. Lots of learning happened in both directions. And lots of stuff for me to report back on at this blog — starting today.
Images and PDF sizes
We do not support linked images from PDF files. Remember, the "P" in PDF means "Portable". If the file has references to external content, it isn’t exactly portable. Another issue with linked images is that a PDF file with an external reference cannot reliably embed a digital signature.
In your XFA template you have the choice to link or embed images. But the final PDF will always have the images embedded — even if the template referenced them with a link.
Given that, what factors do you consider when you choose whether to embed or link images in your XFA templates? Choosing between the two has size implications in the generated PDF. Here is a bit of detail on how they get processed:
Embedded images are stored in the XFA template XML as a base64-encoded value. As with all base64 encoded binary data, the size expands by a factor of 4/3. When Adobe Reader renders a dynamic form, it extracts the image data from the template and draws it to the screen. If a template embeds the same image multiple times, we carry all copies of the duplicated image in the template and consequently, inside the PDF.
When we create a PDF from an XFA template with linked images, the images are stored in a PDF resource area. We create an indexed name for the image based on the image file reference. There are two efficiencies gained here:
- The images are stored in binary format — not base64 encoded
- Multiple references to the same image are reconciled to a single copy of that image in the PDF
So clearly, if you are including images, and especially if you are including multiple copies of the same image in your XFA form, your final PDF will be smaller when you include those images as links instead of by embedding.