Describe the bug
If you use ngIf to hide and show the viewer pressing print button in between, the first printing works. All following print attempts wont work anymore. The error in console is: Expected print service to be initialized.
Version info
Desktop (please complete the following information):
To Reproduce
In production we display the pdf viewer if some resource returns a pdf as base64 and we hide it after printing and if no pdf is loaded. The main principle can be retraced with the following example project: https://github.com/i7i5/pdf-example
The print prompt wont show up again and in console you get the following error:
Expected print service to be initialized. 2 viewer-2.6.418.min.js:43:234879
printPDF http://localhost:4200/assets/viewer-2.6.418.min.js:43
webViewerPrint http://localhost:4200/assets/viewer-2.6.418.min.js:43
dispatch http://localhost:4200/assets/viewer-2.6.418.min.js:43
dispatch http://localhost:4200/assets/viewer-2.6.418.min.js:43
_bindListeners http://localhost:4200/assets/viewer-2.6.418.min.js:43
invokeTask http://localhost:4200/polyfills.js:9563
runTask http://localhost:4200/polyfills.js:9331
invokeTask http://localhost:4200/polyfills.js:9644
invokeTask http://localhost:4200/polyfills.js:10785
globalZoneAwareCallback http://localhost:4200/polyfills.js:10811
(Async: EventListener.handleEvent)
customScheduleGlobal http://localhost:4200/polyfills.js:10937
scheduleTask http://localhost:4200/polyfills.js:9549
scheduleTask http://localhost:4200/polyfills.js:9374
scheduleEventTask http://localhost:4200/polyfills.js:9400
makeAddListener http://localhost:4200/polyfills.js:11092
_bindListeners http://localhost:4200/assets/viewer-2.6.418.min.js:43
Toolbar http://localhost:4200/assets/viewer-2.6.418.min.js:43
_initializeViewerComponents http://localhost:4200/assets/viewer-2.6.418.min.js:43
initialize http://localhost:4200/assets/viewer-2.6.418.min.js:43
run http://localhost:4200/assets/viewer-2.6.418.min.js:43
webViewerLoad http://localhost:4200/assets/viewer-2.6.418.min.js:43
doInitPDFViewer http://localhost:4200/vendor.js:13287
invokeTask http://localhost:4200/polyfills.js:9563
onInvokeTask http://localhost:4200/vendor.js:53839
invokeTask http://localhost:4200/polyfills.js:9562
runTask http://localhost:4200/polyfills.js:9331
invokeTask http://localhost:4200/polyfills.js:9644
invoke http://localhost:4200/polyfills.js:9633
timer http://localhost:4200/polyfills.js:11716
(Async: setTimeout handler)
scheduleTask http://localhost:4200/polyfills.js:11737
scheduleTask http://localhost:4200/polyfills.js:9549
onScheduleTask http://localhost:4200/polyfills.js:9436
scheduleTask http://localhost:4200/polyfills.js:9542
scheduleTask http://localhost:4200/polyfills.js:9374
scheduleMacroTask http://localhost:4200/polyfills.js:9397
scheduleMacroTaskWithCurrentZone http://localhost:4200/polyfills.js:10298
setNative http://localhost:4200/polyfills.js:11750
name http://localhost:4200/polyfills.js:10613
doInitPDFViewer http://localhost:4200/vendor.js:13270
ngAfterViewInit http://localhost:4200/vendor.js:13075
callHook http://localhost:4200/vendor.js:28065
callHooks http://localhost:4200/vendor.js:28035
executeInitAndCheckHooks http://localhost:4200/vendor.js:27987
refreshView http://localhost:4200/vendor.js:34826
refreshEmbeddedViews http://localhost:4200/vendor.js:35862
refreshView http://localhost:4200/vendor.js:34779
refreshComponent http://localhost:4200/vendor.js:35908
refreshChildComponents http://localhost:4200/vendor.js:34552
refreshView http://localhost:4200/vendor.js:34805
renderComponentOrTemplate http://localhost:4200/vendor.js:34869
tickRootContext http://localhost:4200/vendor.js:36082
detectChangesInRootView http://localhost:4200/vendor.js:36107
detectChanges http://localhost:4200/vendor.js:48112
tick http://localhost:4200/vendor.js:54765
next http://localhost:4200/vendor.js:54654
invoke http://localhost:4200/polyfills.js:9528
onInvoke http://localhost:4200/vendor.js:53851
invoke http://localhost:4200/polyfills.js:9527
run http://localhost:4200/polyfills.js:9287
I also tried this example with the bleeding edge trigger on (see bleeding-edge branch) but with the newest pdfjs version the afterPrint output doesnt work correctly. I am also not sure if its a bug of this lib or of the pdfjs lib. If its on pdfjs side how to report it to them?
I hope this report helps to find the bug.
BR
Hey, cool, you've send not only one, but two reproducers! Thanks a lot!
As for the bleeding edge branch: I've started to merge the latest changes from pdf.js manually, and that's always an error-prone process. So I assume it's my bug.
This week I'm very busy, so I can't promise you to solve the bug soon.
The bugfix has landed with version 7.1.0.
Enjoy!
Stephan
Thank you a lot, works like a charm :)
I wish you a nice third advent!
i7