---
title: "Save & download PDF files using JavaScript | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/save-a-document/"
md_url: "https://www.nutrient.io/guides/web/save-a-document.md"
last_updated: "2026-05-18T13:37:23.550Z"
description: "Learn the secret to effortlessly save and manage documents online. Discover our sample code for document saving with Nutrient today."
---

# Save PDF files using JavaScript

Nutrient Web SDK includes support for client-side PDF saving using JavaScript (without a server). Edited or newly created PDFs can be saved to an ArrayBuffer, to a remote server, or to local storage.

[Try for Free](https://www.nutrient.io/sdk/web/getting-started.md)

[Launch Demo](https://www.nutrient.io/demo/)

## Quick start

Export any open PDF to an `ArrayBuffer` with a single API call:

```js

// Get the PDF as an `ArrayBuffer`.
const buffer = await instance.exportPDF();

```

### Download to local file

Trigger a browser download from the exported buffer:

```js

// Export and download the PDF.
const buffer = await instance.exportPDF();
const blob = new Blob([buffer], { type: "application/pdf" });
const url = URL.createObjectURL(blob);

const a = document.createElement("a");
a.href = url;
a.download = "document.pdf";
document.body.appendChild(a);
a.click();

URL.revokeObjectURL(url);
document.body.removeChild(a);

```

### Send to a server

Post the exported PDF to your backend:

```js

const buffer = await instance.exportPDF();

await fetch("/api/documents", {
  method: "POST",
  headers: { "Content-Type": "application/pdf" },
  body: buffer,
});

```

### Add a download button to the toolbar

Combine saving with UI customization:

```js

let instance;

const downloadButton = {
  type: "custom",
  id: "download-pdf",
  icon: "/icons/download.svg",
  title: "Download",
  onPress: async () => {
    const buffer = await instance.exportPDF();
    const blob = new Blob([buffer], { type: "application/pdf" });
    const url = URL.createObjectURL(blob);

    const a = document.createElement("a");
    a.href = url;
    a.download = "document.pdf";
    a.click();

    URL.revokeObjectURL(url);
  },
};

const toolbarItems = NutrientViewer.defaultToolbarItems;
toolbarItems.push(downloadButton);

instance = await NutrientViewer.load({
  container: "#viewer",

  document: "/path/to/document.pdf",
  toolbarItems,
});

```

## Key capabilities

- **Local storage or remote URL** — Save PDF files to any location

- **Incremental save** — Improve performance when saving large PDFs

- **Auto save** — Automatically save edits to the file

- **Client-side** — Save PDFs directly in the browser (no server needed)

- **Headless** — Edited or newly created files can be saved without a UI

- **Extendable** — Add annotation, signing, editing, forms, and more

## Guides for saving a document

**[Save a document to local storage](https://www.nutrient.io/guides/web/save-a-document/to-local-storage.md)**\
How to save a document to local storage

**[Save a document to an ArrayBuffer](https://www.nutrient.io/guides/web/save-a-document/to-arraybuffer.md)**\
How to save a document to an ArrayBuffer

**[Save a document to a remote server](https://www.nutrient.io/guides/web/save-a-document/to-remote-server.md)**\
How to save a document to a remote server

**[Save a document to  Document Engine](https://www.nutrient.io/guides/web/save-a-document/to-document-engine.md)**\
How to save a document to Document Engine

**[Incremental saving](https://www.nutrient.io/guides/web/features/document-processing.md)**\
How to append changes to the end of a PDF, instead of rewriting

**[Auto-save](https://www.nutrient.io/guides/web/features/saving.md)**\
How to configure the way changes are automatically saved

**[Save as](https://www.nutrient.io/guides/web/save-a-document/save-as.md)**

How to save a document as a new file

**[Detect unsaved changes](https://www.nutrient.io/guides/web/save-a-document/detect-unsaved-changes.md)**\
How to check for unsaved changes and register state change listeners

**Call to Action**

Start your free trial for unlimited access and expert support.

[Learn More](https://www.nutrient.io/sdk/web/getting-started/other-frameworks/javascript.md)
---

## Related pages

- [Auto-saving PDF changes in our JavaScript viewer](/guides/web/features/saving.md)
- [Save PDFs to Document Engine using JavaScript](/guides/web/save-a-document/to-document-engine.md)
- [Save PDFs to local storage using JavaScript](/guides/web/save-a-document/to-local-storage.md)
- [Detecting unsaved changes in PDFs](/guides/web/save-a-document/detect-unsaved-changes.md)
- [Save documents as PDFs on the web](/guides/web/save-a-document/save-as.md)
- [Save PDFs to a remote server using JavaScript](/guides/web/save-a-document/to-remote-server.md)
- [Enable incremental saving of PDFs using JavaScript](/guides/web/features/document-processing.md)
- [Save PDFs to an ArrayBuffer using JavaScript](/guides/web/save-a-document/to-arraybuffer.md)
- [Save PDF without annotations using JavaScript](/guides/web/save-a-document/without-annotations.md)

