This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/web/forms/fill-form-fields/attach-a-file.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Attach a file to PDF form using JavaScript | Nutrient SDK

Image annotations include the image as an attachment. In order to create an image annotation, the attachment has to be created first.

Attachments can be created by passing the Blob of the file to be attached to instance#createAttachment, which returns a Promise resolving to the attachment ID, which can then be used to create the image annotation:

NutrientViewer.load(configuration).then(async (instance) => {
// attachmentBlob contains a PNG image file
const imageAttachmentId = await instance.createAttachment(attachmentBlob);
const imageAnnotation = new NutrientViewer.Annotations.ImageAnnotation({
imageAttachmentId,
contentType: 'image/png',
pageIndex: 0,
boundingBox: new NutrientViewer.Geometry.Rect({
width: 100,
height: 100,
top: 100,
left: 100
})
});
const [createdAnnotation] = await instance.create(imageAnnotation);
});