Add image to acrofield in iText?

后端 未结 3 1232
逝去的感伤
逝去的感伤 2020-12-09 12:40

I\'m trying to fill PDF using acrofields, I\'m able to add string data perfectly, but having issues in adding images to acrofields. This is my code for adding string data..

3条回答
  •  我在风中等你
    2020-12-09 13:01

    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 as described in my book:

    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.

    DISCLAIMER: I'm the original developer of iText and the author of the "iText in Action" books.

提交回复
热议问题