diff --git a/src/utils/print.ts b/src/utils/print.ts index 3a58357d..5498e5a5 100644 --- a/src/utils/print.ts +++ b/src/utils/print.ts @@ -74,8 +74,13 @@ export const print = (printNode: HTMLElement, size: PageSize) => { const handleLoadIframe = () => { iframeContentWindow.focus() iframeContentWindow.print() + } + + const handleAfterprint = () => { + iframeContentWindow.removeEventListener('afterprint', handleAfterprint) document.body.removeChild(iframe) } iframe.addEventListener('load', handleLoadIframe) + iframeContentWindow.addEventListener('afterprint', handleAfterprint) } \ No newline at end of file