Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng2-pdf-viewer is broken since version 10.3.0 #1132

Open
2 of 4 tasks
FrancescoBorzi opened this issue Sep 13, 2024 · 8 comments
Open
2 of 4 tasks

ng2-pdf-viewer is broken since version 10.3.0 #1132

FrancescoBorzi opened this issue Sep 13, 2024 · 8 comments

Comments

@FrancescoBorzi
Copy link

Bug Report or Feature Request (mark with an x)
  • Regression (a behavior that used to work and stopped working in a new release)
  • Bug report -> please search issues before submitting
  • Feature request
  • Documentation issue or request

We have been using version 10.2.2 and it worked fine:

image

Since version 10.3.0 it is broken (we tried also 10.3.1, same result). The component simply does not show up anymore, without any meaningful error:

image

We also noticed that internally the component changed the dependency version of pdfjs-dist from 3.x to 4.x, which might be the cause of the issue.

This was the change that broke it on our app:

image

@shamoon
Copy link
Contributor

shamoon commented Sep 13, 2024

Without an error of some kind or at least more debugging I’m not sure there’s much to do here or how to help.

The package isn’t generally broken so it seems like you need to do more work locating the issue. Is the viewer loading but somehow not visible? Is something about the way you implemented it making the component invisible (eg height 0)? Etc

Agree it’s unexpected between versions. This being FOSS, the onus is much more on you as the developer…

@studioromeo
Copy link
Contributor

Confirmed this issue. Haven't been able to look into the cause yet but downgrading to 10.2.2 does resolve.

@shamoon
Copy link
Contributor

shamoon commented Sep 13, 2024

With respect, “me too” isn’t that helpful either. Again, it doesn’t seem to affect most…

@Francesco-Borzi
Copy link

Without an error of some kind or at least more debugging I’m not sure there’s much to do here or how to help.

The package isn’t generally broken so it seems like you need to do more work locating the issue. Is the viewer loading but somehow not visible? Is something about the way you implemented it making the component invisible (eg height 0)? Etc

Agree it’s unexpected between versions. This being FOSS, the onus is much more on you as the developer…

@shamoon I totally agree. I've just couldn't have the chance to investigate more on this. Reporting the issue is already a good start to track the problem and give others the possibility to confirm it and add more details.

With respect, “me too” isn’t that helpful either. Again, it doesn’t seem to affect most…

@shamoon I disagree on that. Of course, more details would be ideal, but even just knowing that other users are experiencing the same issue is already a small piece of useful information. So thanks @studioromeo for confirming.

@shamoon
Copy link
Contributor

shamoon commented Sep 13, 2024

Yea I dont want to get into a tit-for-tat and distract here but I'll just say that without an actual error or specific description there is no real certainty that you are actually experiencing the same issue.

Anyway, we'll see. If I can help I'll be happy too

@Francesco-Borzi
Copy link

there is no real certainty that you are actually experiencing the same issue.

well, there is no 100% certainty but I'm 99% sure, given that:

downgrading to 10.2.2 does resolve

for both it works fine on 10.2.2 and it doesn't work after that.

@studioromeo
Copy link
Contributor

Hi @Francesco-Borzi

Are you using pdfWorkerSrc by any chance? I can see that the file names have changed from pdf.worker.js to pdf.worker.mjs (and min files change similarly).

In my test project appears to be the cause of the failure that resolves when downgrading to 10.2.2. Correcting the path to use the .mjs extension resolves on 10.3.x

The docs still references .js files so I have raised a PR to to avoid potential confusion #1134

It's worth considering a major release as while this is a breaking change in a child dependency, and this projects API has not been affected directly, it does expose the global pdf.js API and therefore represents a significant risk to consumers.

Thanks!

@mibadim
Copy link

mibadim commented Sep 16, 2024

Not sure the problem I experienced was the same, but at least it it turned out ng2-pdf-viewer works fine for me. PDFs were not displayed:

grafik

The console said:

pdf-preview.component.ts:33[Image Preview]: Error occured Error: Setting up fake worker failed: "Failed to fetch dynamically imported module: http://localhost:2362/microcore/cpaval/ui/pdf.worker.js".
    at pdf.mjs:12000:36
    at _ZoneDelegate.invoke (zone.js:368:26)
    at Object.onInvoke (core.mjs:11083:33)
    at _ZoneDelegate.invoke (zone.js:367:52)
    at Zone.run (zone.js:129:43)
    at zone.js:1257:36
    at _ZoneDelegate.invokeTask (zone.js:402:31)
    at core.mjs:10757:55
    at AsyncStackTaggingZoneSpec.onInvokeTask (core.mjs:10757:36)
    at _ZoneDelegate.invokeTask (zone.js:401:60)

Turned out I had this line in my main.ts:

(window as any).pdfWorkerSrc = '/rootpath/ui/pdf.worker.js';

Changing it to

(window as any).pdfWorkerSrc = '/rootpath/ui/pdf.worker.mjs';

Solved the issue.

Repository owner deleted a comment Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

12 participants
@FrancescoBorzi @studioromeo @shamoon @mibadim @Francesco-Borzi and others