In my web application I am trying to print the contents of the screen. Although when I go to click the button to print, it throws me the following error
core.js:15714 ERROR Error: The overlay manager has not yet been initialized.
at ensureOverlay (viewer.js:15555)
at print (viewer.js:15449)
at PrintCoverScanComponent.push../src/app/feature-modules/coverscan/component/print-coverscan.component.ts.PrintCoverScanComponent.printCoverPage (print-coverscan.component.ts:135)
at SafeSubscriber._next (print-coverscan.component.ts:95)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:196)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)
at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
I have checked everywhere in google, but have found nothing. I've tried calling the function on load to be sure it wasn't the button causing anything.
<div *ngIf="!progressSpinnerEnabled" class="d-print-none">
<hr />
<button type="submit" style="float: right; margin-bottom: 10px;" nz-button nzType="primary" (click)="printCoverPage()">Print</button>
</div>
printCoverPage() {
window.print();
}
Additional info added by Stephan Rauh: the application is using Mozilla's pdf.js (more precisely: <ngx-extended-pdf-viewer>
).
Update 06/07/2019: I've published a new version of <ngx-extended-pdf-viewer>
. Please update to version 0.9.54 or above. This version stops overriding window.print()
and fixes several other bugs related to printing.
Original answer:
ngx-extended-pdf-viewer author here. I wouldn't call it a bug, because the pdf.js team clearly intended to override the standard print()
function. However, I have to admit that it's a bug in your application, so we should fix it.
I've started to work on the topic. I've published a preliminary bug fix with ngx-pdf-viewer 0.9.53. See https://github.com/stephanrauh/ngx-extended-pdf-viewer/issues/101 and how to activate the bug fix (it's only included in the developer preview).
I'll edit this answer again after successfully (or so I hope!) fixing the bug and bringing it to the main branch of ngx-extended-pdf-viewer.