ngx-extended-pdf-viewer
ngx-extended-pdf-viewer copied to clipboard
[Regression] when [src] is updated, it seems that the pageRendered() is called twice for version >=19.2.0
Hello, First, thanks a lot for your great component,
As discussed here for onPDFLoaded event, it seems that since version 19.2.0 the event pageRendered is also called twice. Did some tests with version <= 19.1.0 is ok. Bad behavior for all version >= 19.2.0.
- Version of ngx-extended-pdf-viewer
=19.2.0
I will try to understand it based on the diff between 19.1.0 and 19.2.0.
Regards
Olivier
https://github.com/stephanrauh/ngx-extended-pdf-viewer/commit/1ba0c7bde7e38a137a39bf740eff4b567064190e
I will investigate this commit that seems to introduce the regression
As far as I can see, it only happens for the first page. And it does not happen when opening a new file using the "open file" button.
Maybe it's a timing issue. The commit you've found registers the event listeners even if [src]
is falsy. Maybe the code is called multiple times, and because of the missing if statement it's executed earlier now.
Another observation: the render events have a different scale
. Maybe the first page is rendered before the correct zoom setting is calculated. If you set [zoom]="'100%'"
, there's only one event.
yes good point, other details in this direction. I do not have the same behavior on chrome and firefox. Probably, on firefox, the zoom is correctly computed before the rendering
It's a long time ago... but I faintly remember I had some trouble implementing the [zoom]
attribute. As far as I remember, the compromise was to wait until the page finished rendering and to set the [zoom]
setting afterwards.
BTW, I'm afraid Chrome support will always be worse than Firefox support. That's because pdf.js is the PDF engine of Firefox. Nothing more and nothing less. What we're doing here is tolerated by the pdf.js team, but they don't support it actively (unless I ask very, very kindly and I'm lucky). In particular, they support Chrome, but only most of the time.