Attach a File to a PDF Form Using JavaScript

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:

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