Convert Images to PDFs Using JavaScript

Converting images to PDF documents is easy with PSPDFKit for Web: You only need to open an image as you would open a document, and export it as a PDF.

The following example showcases this workflow in Standalone mode:

PSPDFKit.load({
  document: "https://example.com/myimage.png"
}).then(async (instance) => {
  const documentArrayBuffer = await instance.exportPDF();
});

The resulting ArrayBuffer from instance.exportPDF() can then be downloaded or persisted in the storage of your choice.

Supported image formats include PNG, JPEG, and TIFF.

When exporting a document, there are several options available. Refer to our guides on flattening annotations and incremental saving for more details.

Auto saving can be configured for different scenarios and use cases. You can find more information in our auto save guide.

You can check out the document saving guides for more details about downloading or persisting the exported ArrayBuffer.