# PDFViewer.hasUnsavedChanges

```ts
get hasUnsavedChanges(): boolean
```

`true` from the first change on — a tool's, a page's, a field filled in or signed, the document API's, an undo — until the document is exported whole by an exporter from [createExporter()](https://kernstra.com/docs/web-sdk/api/pdfviewer/createexporter) (the toolbar's Download; `download()`, `getBlob()`, `getArrayBuffer()`, `getBase64()`, `uploadTo()` without `pages`) or [markSaved()](https://kernstra.com/docs/web-sdk/api/pdfviewer/marksaved) is called. A change made while an export ran stays unsaved; an undo back to the saved state still counts. [documentChanged](https://kernstra.com/docs/web-sdk/api/events#ev-documentchanged) reports every change of it; nothing reports it going back to `false`. The export is the "save": a host that uploads the bytes keeps its own flag for an upload that failed, or a "leave without saving?" guard lets the user go after one — see [Saving as the user works](https://kernstra.com/docs/web-sdk/guides/replace).

- Kind: getter
- Since: 1.0.0

Returns `boolean`

```ts
window.addEventListener('beforeunload', (e) => {
  if (viewer.hasUnsavedChanges) e.preventDefault();
});
```

Part of [PDFViewer](https://kernstra.com/docs/web-sdk/api/pdfviewer) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/pdfviewer/hasunsavedchanges
