ngx-extended-pdf-viewer
ngx-extended-pdf-viewer copied to clipboard
Text dissapears when using the pdf viewer in a separate window
We use this pdf viewer in our Angular application to view pdf's in a separate window (using window.open)
Describe the bug
- Open the pdf viewer in a separate window
- Zoom or resize the window
- The text dissapears, squares are shown instead
Version info
- 19.2.0
I am also running into this in v20.
Is there any error message in the console? Does it happen with every PDF file, or are only certain PDF files affected?
I also saw this happen on the Mozilla PDF viewer, so maybe it's a core bug.
If you interact, and do something like zooming then the PDF re renders and everything appears again.
We don't have any error messages in the console when the text dissapears.
It does not happen with every pdf. We checked these pdf's in the Mozilla PDF viewer, there we did not have this issue.
I'm not sure how to reproduce the bug. Can you send me a simple reproducer, please?
Yes, I have created a simple Angular application with the pdf viewer in a pop out window: https://github.com/Yasmin-van-Dijk/demo-pop-out-pdf-viewer/tree/master
I've downloaded your reproducer. Now I can reproduce your issue. Thanks!
I'm afraid your issue required much more knowledge about pdf.js than I have. I can give you a few qualified guesses after debugging a few hours.
- The problem occurs in the worker thread. However, even by forcing the worker to run in the main thread, I couldn't see any error message, nor a failing file access, nor an exception.
- Using a custom assets path seems to confuse the viewer. Using the standard
/assetspath makes a difference. However, I wouldn't call it progress: instead of showing boxes it renders an empty page. - However, if you're using a Japanese file loading the font definition from the external file
assets/cmaps/Adobe-Japan1-UCS2.bcmap, the viewer worked flawlessly in the window. It's possible to use different zoom settings, and the file renders correctly.
However, even with the Japanese file, the viewer was slightly broken in the window. Hitting the "+" and "-" buttons to modify the zoom setting resulted in weird jumps of the zoom level.
I suspect the viewer is ill prepared for loading its resources in one window and running the code in another window. To be honest, I'm surprised it's possible at all - I didn't expect that. Adding insult to injury, I believe it's a bug (or peculiarity?) of the base library, so I don't believe I'm able to fix it.
As a workaround, I suggest either using modal dialogs or using window.open() with the native viewer of the browser. Opening an <iframe> in the new browser should also work.
I'm sorry I can't provide a solution - but I believe this is one of the hard problems! I hope at least one of my workarounds suits you.
Best regards, Stephan
I've closed the ticket, but I'm still listening to this channel. If you've got new insight, don't hesitate to tell me.
Hi Stephan,
Thanks for looking into this! We will try your suggested workarounds.