onLoadProgress total is NaN when fetching a pdf from a url
shihabdider opened this issue · comments
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):