Save PDFs to an ArrayBuffer using JavaScript
Exporting a PDF to an ArrayBuffer can be done with a single API call to instance.exportPDF():
try { const documentBuffer = await instance.exportPDF(); console.log("PDF exported successfully");} catch (error) { console.error("Failed to export PDF:", error.message);}Try this example in the Playground(opens in a new tab).
The resolved ArrayBuffer can then be handled as desired — for example, send it to your server or download it to a local storage.
Under AutoSaveMode.DISABLED, the exported file doesn’t include unsaved annotations. The export succeeds, and instance.hasUnsavedChanges() stays true. In standalone mode, unsaved form field values may already be present in the export, because NutrientViewer.Options.PDF_JAVASCRIPT is enabled by default. An export without a save can therefore contain some pending edits but not others. Call instance.save() before you export to include everything. In server-backed mode, saving also persists those changes to Document Engine.
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.