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?

25th October 2015

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);
form.replacePushbuttonField("advertisement", ad.getField());

See for the full code sample.


Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now