Adding an Image to a PDF Form Using JavaScript

It’s possible to create image annotations using the UI using the corresponding toolbar button:

Image annotations toolbar button

Pressing the button will open a file select dialog which will allow you to choose a PNG, JPEG or PDF file to use as attachment for the annotation.

Image file selector

Once the image is picked, the image annotation will be created in the current page with the selected image. When selected, you can use the UI to move it, resize it, or change its opacity:

Image annotation

The attachment is included along with the image annotation when changes are persisted to the document.

Images included using the UI can also be programmatically extracted if needed by passing the attachment ID to instance#getAttachment, which will resolve to a Blob containing the image file.

const attachmentBlob = await instance.getAttachment(imageAnnotation.imageAttachmentId);

We use cookies to improve your experience and for marketing. Learn more in our privacy policy.