Detecting Unsaved Changes in PDFs

You can check to see if there are any unsaved changes to a document by calling Instance#hasUnsavedChanges.

If you wish to react to saved state changes, you can register listeners for the document.saveStateChange event. The emitted event contains the hasUnsavedChanges property, with the current value returned by the Instance#hasUnsavedChanges method:

instance.addEventListener("document.saveStateChange", (event) => {
  console.log(`Save state changed: ${event.hasUnsavedChanges}`);