PDFViewer.destroy()
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() 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.
Signature
Returns
void
Example
viewer.destroy(); await doc.close();