VadimDez/ng2-pdf-viewer

no resource to load, early way out angular 16

Xcaliburx opened this issue · 15 comments

no resource to load, early way out in angular 16. Please help
image

when i add a specific height, it works but i don't really want to do this

Just updated from 9.1.0 to 10.0.0 and see the same in console.

So basically after debugging - that's my findings:

  • log comes from pdf.js library
  • there is loadLocale funtion, which responsible to load localization, but some for reason localization is not present.

I think that the right place for this issue is here https://github.com/mozilla/pdf.js/issues/new

After upgrading to Angular 16 and ng-pdf-viewer to 10.0.0 I got the same issue.

How I resolved it:

  • Downgrade to 9.xx
  • Set height & width of pdf-viewer component (to 100%)

Here are my dependencies:

"ng2-pdf-viewer": "9.1.5"
"@angular/core": "16.2.9"

I'm on Angular 17 and ng-pdf-viewer 10.0.0, hit the same problem.

Downgrading didnt help me.

When I gave the viewer a height it worked but the scroll bar was then inside the page margin, i needed the viewer to render at full height to get the page to do the scrolling so I tried this and it worked for me:

:host ::ng-deep .ng2-pdf-viewer-container {
  height: auto !important;
  overflow-y: hidden !important;
}

I am on angular 16 and ng2-pdf-viewer = 10.0.0. The viewer is not displaying pdf. Same code was working 2 days back.
Any change happened.

If i copy the contents of the page, it seems the pdf is generated but not visible. putting :
style="width: 100%; height: 100vh; z-index: 9999;" inside the pdf-viewer component fixed it for me.

a css class would also work offcourse.

@iliasaddab can you please confirm below code which I added style

<pdf-viewer [src]="someData?.fileURL" (page-rendered)="pageRendered()"
(after-load-complete)="someEvent($event)" [original-size]="false" [page]="page"
[render-text]="renderText" [autoresize]="true" [show-all]="false" class="pdf-container"
style="width: 100%; height: 100%;z-index: 9999;">

        In my case is not working and getting console page "no resource to load, early way out"

@iliasaddab can you please confirm below code which I added style

<pdf-viewer [src]="someData?.fileURL" (page-rendered)="pageRendered()" (after-load-complete)="someEvent($event)" [original-size]="false" [page]="page" [render-text]="renderText" [autoresize]="true" [show-all]="false" class="pdf-container" style="width: 100%; height: 100%;z-index: 9999;">

        In my case is not working and getting console page "no resource to load, early way out"

yes try that

@iliasaddab can you please confirm below code which I added style

<pdf-viewer [src]="someData?.fileURL" (page-rendered)="pageRendered()" (after-load-complete)="someEvent($event)" [original-size]="false" [page]="page" [render-text]="renderText" [autoresize]="true" [show-all]="false" class="pdf-container" style="width: 100%; height: 100%;z-index: 9999;">

        In my case is not working and getting console page "no resource to load, early way out"

oh wait try the parent element with a fixed height and width eg. 1000px
and the pdf component with style="width: 100vh; height: 100vh;z-index: 9999;"
i changed it to VH not %.

Scherm­afbeelding 2024-06-07 om 13 58 33

@iliasaddab Yes, after adding only height: 100vh, i'm able to view file now thank you.
Can you also explain why we need to add explicitly height. Once again thanks alot.

@iliasaddab Yes, after adding only height: 100vh, i'm able to view file now thank you.
Can you also explain why we need to add explicitly height. Once again thanks alot.

Because the page two way binding only works then. See docs.

@iliasaddab Yes, after adding only height: 100vh, i'm able to view file now thank you.
Can you also explain why we need to add explicitly height. Once again thanks alot.

Because the page two way binding only works then. See docs.

Ok I found thank you

@angular/cli": "17.3.6"
ng2-pdf-viewer": "^10.2.2"

Console page getting no resource to load, early way out, Please someone help me for that

I have a similar problem in v 10.2.2. The pdf gets displayed and I get same error "no resource to load, early way out" and the variable holding the Uint8Array of the PDF gets ereased. Its empty then.