From d6e2456bafe95629b97834ac2cc5330d21b7b7de Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 30 Oct 2025 15:14:44 -0700 Subject: [PATCH] Update document-detail.component.ts --- .../document-detail.component.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 4e0d3259f..e7197b9b9 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -1448,16 +1448,23 @@ export class DocumentDetailComponent iframe.contentWindow.focus() iframe.contentWindow.print() iframe.contentWindow.onafterprint = () => { - timer(500).subscribe(() => { - // delay to avoid print failure + timer(100).subscribe(() => { + // delay to avoid FF print failure document.body.removeChild(iframe) URL.revokeObjectURL(blobUrl) }) } } catch (err) { - this.toastService.showError($localize`Print failed.`, err) - timer(500).subscribe(() => { - // delay to avoid print failure + const isCrossOriginAfterPrintError = + err instanceof DOMException && + (err.name === 'SecurityError' || + err.message.includes('onafterprint')) && + err.message.includes('cross-origin') + if (!isCrossOriginAfterPrintError) { + this.toastService.showError($localize`Print failed.`, err) + } + timer(100).subscribe(() => { + // delay to avoid FF print failure document.body.removeChild(iframe) URL.revokeObjectURL(blobUrl) })