Link to PDF file (or attach file here):
Untitled.pdf
Configuration:
What is the expected behavior?
Get the total size of the pdf when loading it in order to make a Loading Bar
What went wrong?
When I am loading a pdf, I receive a total pdf size: "undefined" while it should display "11405" from the beginning. (You can notice that it display the right pdf size when the loading is finished)
onProgress: function ChunkedStreamManager_onProgress(args) {
---------------- : bytesLoaded : 8234
---------------- : data.total : 0
---------------- : this._contentLength : undefined
fullRequest.onProgress = function (evt) {
---------------- evt : Object {loaded: 8234, total: undefined}
---------------- : Loaded : 8234
---------------- : total : undefined
progress : Object {loaded: 8234, total: undefined}
onProgress: function ChunkedStreamManager_onProgress(args) {
---------------- : bytesLoaded : 11405
---------------- : data.total : 0
---------------- : this._contentLength : undefined
fullRequest.onProgress = function (evt) {
---------------- : evt : Object {loaded: 11405, total: undefined}
---------------- : Loaded : 11405
---------------- : total : undefined
progress : Object {loaded: 11405, total: undefined}
fvar readPromise = new Promise(function (resolve, reject) {
---------------- : Loaded : 11405
---------------- : total : 11405
progress : Object {loaded: 11405, total: 11405}
I believe it comes from my server setup since I don't have this error when serving this pdf with : http-server
But in order to fully understand where the problem comes from, I need to understand the data-flow. Could you explain how the onProgress
method works when we call getDocument
, how and when the onProgress parameter are set (loaded and total) ? I didn't see any precise documentation on that point.
Thanks
a.d
Same here, file size keeps unknown until fetched.
When I am loading a pdf, I receive a total pdf size: "undefined" while it should display "11405" from the beginning.
HTTP protocol might not specify total length of the content. Notice even if Content-Length header is specified it might be wrong or specify lengths of the compressed content. If PDF.js not sure or does not know about lengths of PDF, the total is undefined. Closing as answered.
Most helpful comment
HTTP protocol might not specify total length of the content. Notice even if Content-Length header is specified it might be wrong or specify lengths of the compressed content. If PDF.js not sure or does not know about lengths of PDF, the total is undefined. Closing as answered.