# PDFViewer.destroy()

```ts
destroy(): void
```

Removes everything the viewer added to the page: its DOM, every document- and window-level listener, observers, timers, the render worker, its tools, and any of its dialogs or popovers still open (a pending `print()` resolves without printing). Safe to call twice. A shape or annotation still selected goes back into the document where it was. With the last viewer on the page it also removes the shared stylesheets. The Image tool's recent images, saved signatures and user stamps stay for the page session, for the next viewer.

**It does not close the underlying `PDFDocument`** — call [document.close()](https://kernstra.com/docs/web-sdk/api/pdfdocument/close) yourself, before or after, or you leak its memory. After it, every member that acts — `goToPage()`, `setScale()`, `activateTool()`, `print()`, `search()`, `openPanel()`, `undo()`, `createExporter()` and the rest — throws `INVALID_STATE` rather than doing nothing; the getters keep answering their last values. A stale handler that still reaches the viewer is a bug this makes visible.

- Kind: method
- Since: 1.0.0

Returns `void`

```ts
viewer.destroy();
await doc.close();
```

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/destroy
