【发布时间】:2019-11-04 18:12:30
【问题描述】:
在我的网络应用程序中,我试图打印屏幕的内容。虽然当我点击按钮打印时,它会抛出以下错误
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)
我在 google 中到处检查过,但一无所获。我尝试在加载时调用该函数,以确保它不是导致任何事情的按钮。
<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();
}
Stephan Rauh 添加的其他信息:该应用程序正在使用 Mozilla 的 pdf.js(更准确地说:<ngx-extended-pdf-viewer>)。
【问题讨论】:
-
这可能是浏览器支持的问题。您要在哪个浏览器上运行它?是否有一个最小的可重现示例可供我们查看?也许是一个样本StackBlitz?
-
它似乎不适用于 Chrome 和 IE。我不确定如何给你一个合适的例子,因为这个应用程序有很多部分。到目前为止,我还没有一个最小的可重现示例。
-
您要在哪个版本的 Chrome 和 IE 上运行它?
-
Chrome 是 75.0.3770.100,IE 是 11.253.17763.0
-
我也可以在使用 Chrome (75.0.3770.100) 的开发机器上重现它
标签: javascript html angular typescript pdf.js