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

onLoadProgress total is NaN when fetching a pdf from a url #1752

Open
4 tasks done
shihabdider opened this issue Mar 27, 2024 · 0 comments
Open
4 tasks done

onLoadProgress total is NaN when fetching a pdf from a url #1752

shihabdider opened this issue Mar 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@shihabdider
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

I am trying to create a progress bar which displays while the pdf is loading. When fetching a large pdf from a url, the total attribute of the onLoadProgress callback is NaN until the very end, when the pdf is fully loaded (which defeats the purpose of a loading bar).

I suspect this is not really a bug, but I'm wondering how/whether it's possible to get the total by some other means. Otherwise, I can just use a spinning wheel, but the progress bar is obviously better.

Steps to reproduce

Try to load a large pdf by supplying its url to the file prop. Then log the onLoadProgress callback's total attribute.

Expected behavior

Ideally it should compute the total for the fetched document somehow (perhaps using the headers?)

Actual behavior

It set as NaN until the very end. loaded works just fine.

Additional information

No response

Environment

  • Browser (if applicable):
  • React-PDF version:
  • React version:
  • Webpack version (if applicable):
@shihabdider shihabdider added the bug Something isn't working label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant