This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/web/save-a-document/to-local-storage.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Save & download PDF locally from JavaScript viewer | Nutrient

Nutrient Web SDK makes it possible to save an open document locally without a server.

This can be done programmatically by exporting the document to an ArrayBuffer via Instance#exportPDF() and triggering a download.

For example, here you’ll customize the toolbar to add a download button to Nutrient Web SDK (try it in the Playground(opens in a new tab)):

let instance;
const downloadButton = {
type: "custom",
id: "download-pdf",
icon: "/download.svg",
title: "Download",
onPress: () => {
instance
.exportPDF()
.then((buffer) => {
const blob = new Blob([buffer], { type: "application/pdf" });
const fileName = "document.pdf";
// Legacy IE11 support — remove if IE11 is not required.
if (window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, fileName);
} else {
const objectUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = objectUrl;
a.style = "display: none";
a.download = fileName;
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(objectUrl);
document.body.removeChild(a);
}
})
.catch((error) => {
console.error("Failed to export PDF:", error.message);
});
}
};
const items = NutrientViewer.defaultToolbarItems;
// Add the download button to the toolbar.
items.push(downloadButton);
NutrientViewer.load({
toolbarItems: items
})
.then((_instance) => {
instance = _instance;
})
.catch((error) => {
console.error("Failed to load document:", error.message);
});

When you export a document, you can choose how Nutrient Web SDK writes the output. For more information, refer to the flattening annotations guide and the incremental saving guide.

Use autosave to configure when Nutrient Web SDK saves changes. For more information, refer to the autosave guide.

Call instance.save() before exporting if autosave is disabled, or after an undo, redo, or paste. Otherwise, the exported file doesn’t include unsaved annotations.