Recover an Embedded Image

By now I’ve mentioned a bunch of times that it is better to link your images than to embed them.  Most notably in this blog entry.  Just to review the facts one more time:

  • Linked/embedded applies only to the form definition (the template). By the time you generate a PDF, the image is always embedded in the PDF.  But the mechanics of how it is embedded in the PDF differs from embedded to linked.
  • Images embedded in the template are stored in base64 format.  Linked images are stored in binary form.  Base64 is 4/3 bigger than binary
  • Embedded images cause very large form templates. Linked images are stored outside the form template.
  • Embedded images force Designer and Reader to keep the image in DOM memory, resulting in slower open times, higher memory footprint, slower performance in Reader and Designer
  • Same embedded image used <n> times is stored <n> times.  Same linked image used <n> times is stored once

Now, just in case all of that rationale was a bit too much tech-speak (what’s a DOM anyway?) let me simplify the message: Do not embed images in your templates. When you see this pallette, do not check the box.

Lost Images

I predict some of you will look at your forms and realize that you no longer have the original image that you embedded in your template.  It is possible to recover these images and extract them to an external file.  The process is a bit messy, but if you really need it, I’m sure you can figure it out.  Here are the steps:

  1. Find a web site that supports base64 decoding.  A google search for "base64 decode" led me to this site: http://webnet77.com/cgi-bin/helpers/base-64.pl
  2. In Designer, select the image object and then switch to XML source view.  Make note of the contentType.  In the example below, it is image/JPG.  This will tell you what file suffix to use when you download the file.
  3. Copy the base64 image data into your paste buffer.  i.e. select the base64 data and right-click to choose "Copy"
  4. Go to the web site and paste into the "Base64 to Decode" field.  Click the "Process now" button.
  5. Now click the "download binary file now" button.  Save the file using a suffix according to the content type — in this case, with a .jpg extention.

Once you have the image extracted, go back to your form design, re-specify the url to the new image and de-select the embed option.  This would be a great tool to develop into a Designer macro.  Especially given that mx.utils has a Base64Decoder class.