Skip to main content
Skip table of contents

How to add an image to an AcroForm field?

I'm trying to fill out a PDF form using the AcroFields class. I'm able to add text data perfectly, but I'm having issues adding images. How is this done?

Posted on StackOverflow on Apr 17, 2013 by Anil M

The "official" way to do this, is to have a Button field as placeholder for the image, and to replace the "icon" of the button like this:

PushbuttonField ad = form.getNewPushbuttonFromField(imageFieldName);
ad.setLayout(PushbuttonField.LAYOUT_ICON_ONLY);
ad.setProportionalIcon(true);
ad.setImage(Image.getInstance("E:/signature/signature.png"));
form.replacePushbuttonField("advertisement", ad.getField());

See ReplaceIcon.java for the full code sample.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.