mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-11-17 04:16:54 -06:00
Update document-detail.component.ts
This commit is contained in:
@@ -1448,16 +1448,23 @@ export class DocumentDetailComponent
|
|||||||
iframe.contentWindow.focus()
|
iframe.contentWindow.focus()
|
||||||
iframe.contentWindow.print()
|
iframe.contentWindow.print()
|
||||||
iframe.contentWindow.onafterprint = () => {
|
iframe.contentWindow.onafterprint = () => {
|
||||||
timer(500).subscribe(() => {
|
timer(100).subscribe(() => {
|
||||||
// delay to avoid print failure
|
// delay to avoid FF print failure
|
||||||
document.body.removeChild(iframe)
|
document.body.removeChild(iframe)
|
||||||
URL.revokeObjectURL(blobUrl)
|
URL.revokeObjectURL(blobUrl)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
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)
|
this.toastService.showError($localize`Print failed.`, err)
|
||||||
timer(500).subscribe(() => {
|
}
|
||||||
// delay to avoid print failure
|
timer(100).subscribe(() => {
|
||||||
|
// delay to avoid FF print failure
|
||||||
document.body.removeChild(iframe)
|
document.body.removeChild(iframe)
|
||||||
URL.revokeObjectURL(blobUrl)
|
URL.revokeObjectURL(blobUrl)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user