Save PDFs to Document Engine Using JavaScript
When using PSPDFKit for Web in server-backed operational mode, saving a document to the Document Engine backend is easy. Depending on the autoSaveMode set, it can be done automatically with PSPDFKit.AutoSaveMode#IMMEDIATE
and PSPDFKit.AutoSaveMode#INTELLIGENT
, or programmatically on demand by setting PSPDFKit.AutoSaveMode#DISABLED
and calling instance.save
when required.
The following example shows how to set the configuration object so that saving is performed automatically:
PSPDFKit.load({ ...otherOptions, autoSaveMode: PSPDFKit.AutoSaveMode.IMMEDIATE });
If you want more control over when saving is performed, you can disable auto saving and call instance.save
when needed:
PSPDFKit.load({ ...otherOptions, autoSaveMode: PSPDFKit.AutoSaveMode.DISABLED }).then((instance) => { instance.addEventListener("annotations.create", (annotations) => { console.log("annotations created:", annotations.toJS()); // Save changes when new annotations are created. instance.save(); }); });
When exporting a document, you have several options. 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.