There are a number of free and commercial third party tools you could use to convert images to hex-encoded strings. However, none of the tools fits my workflow in terms of flexibility and extensibility. So I have created a Java utility library, called Acrobat Dialog Image Generator (ADIG), which allows you to generate a hex-encoded string or a skeleton Acrobat dialog box with an embedded image.
You can invoke ADIG via a command-line interface, ANT or an API call. Here are some sample invocations:
java -jar adig.jar /Users/lerlop/Pictures/test.jpg /Users/lerlop/Desktop/
ant -buildfile adig.xml
This will also produce the same result as the command-line option but everything is defined in the following build file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="MyProject" default="GeneratorAcrobatDialogImage" basedir=".">
<adig imagePath="/Users/lerlop/Pictures/test.jpg" outputPath="/Users/lerlop/Desktop"/>
String hexString = AcrobatDialogImageGenerator. generateHexEncodedString(imagePath);
- Run ADIG via command-line or ANT to get a generated file. The generate code should like this.
- Open your form in LiveCycle Designer (note: XFA form not AcroForm).
- Create and name a new script object. It does not matter where the script object is located as long as you can reference it later. For simplicity, create it on page 1 and let’s call it DialogSO.
- Copy all the code from the generated file and paste it into the script object.
- Now create a button object so you can use it to launch the dialog box. Note that you could launch the dialog box in any event such as form::docReady or form::initialize.
- The last thing is to make the button launch the dialog box. In the click event of the button, type in the following function call: DialogSO.launchDialog();