---
title: "Generate PDF from image using JavaScript | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/pdf-generation/from-images/"
md_url: "https://www.nutrient.io/guides/web/pdf-generation/from-images.md"
last_updated: "2026-05-25T06:31:34.591Z"
description: "When calling PSPDFKit#load() with Nutrient Web SDK, you can pass either an array buffer or a URL to the image into the document option."
---

# Generate PDFs from images using JavaScript

When calling [`PSPDFKit#load()`](https://www.nutrient.io/api/web/NutrientViewer.html#.load) with Nutrient Web SDK, you can pass either an array buffer or a URL to the image into the `document` option. Or, when calling [`PSPDFKit#load()`](https://www.nutrient.io/api/web/NutrientViewer.html#.load) in Server mode, you can pass the `documentId`. After doing this, Nutrient Web SDK will open the image file as if it were a PDF document:

```js

const res = await fetch("https://example.com/example.tiff");
const imageArrayBuffer = await res.arrayBuffer();
NutrientViewer.load({
  document: imageArrayBuffer
  // Other options.
}).catch((error) => {
  console.error("Failed to load document:", error.message);
});

```

Image documents can be loaded the same way in headless mode by providing the `headless` option:

```js

NutrientViewer.load({
  document: image,
  headless: true
}).catch((error) => {
  console.error("Failed to load document:", error.message);
});

```

For more information on loading options, follow our [guides on importing a PDF document](https://www.nutrient.io/guides/web/open-a-document.md).

## Exporting image documents

Image documents can be exported as PDF documents by using [`Instance#exportPDF()`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#exportPDF) and triggering a download, as explained in the [save a document to local storage](https://www.nutrient.io/guides/web/save-a-document/to-local-storage.md) guide.
---

## Related pages

- [Generate PDFs from a template using JavaScript](/guides/web/pdf-generation/from-pdf-template.md)
- [Headless PDF generation](/guides/web/pdf-generation/headless.md)
- [Generate PDFs from a Word template using JavaScript](/guides/web/pdf-generation/from-word-template.md)
- [Generate a PDF with a PDF form using JavaScript](/guides/web/pdf-generation/from-pdf-form.md)
- [Generate PDF reports using JavaScript](/guides/web/pdf-generation/pdf-reports.md)
- [JavaScript PDF generation library](/guides/web/pdf-generation.md)
- [Generate PDF thumbnails using JavaScript](/guides/web/pdf-generation/thumbnail-preview.md)

