Button Fields and Images
Contents
[
Hide
]
The Java example in FormExamples.addImageAppearanceToButtonField(...) shows how to update a button field appearance with an image stream.
The workflow is straightforward:
- bind the input PDF with
form.bindPdf(...) - open the image file with
Files.newInputStream(...) - call
form.fillImageField(...)for the button field - save the updated PDF
public static void addImageAppearanceToButtonField(Path inputFile, Path imageFile, Path outputFile) throws Exception {
Form form = new Form();
try (InputStream imageStream = Files.newInputStream(imageFile)) {
form.bindPdf(inputFile.toString());
form.fillImageField("Image1_af_image", imageStream);
form.save(outputFile.toString());
} finally {
form.close();
}
}