PDF file download progress callback

Hi,

Is there a callback function I can provide to receive updates about the download of the PDF file? We are trying to expose a large file (100MB), and would like to add a visual element in the page to let the user know about the progress of the download.

Thx

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi There,

If you are talking about loading a file from your server to display in the viewer for a user I would suggest looking into implementing range requests

If you are however talking about the user clicking the download button, and downloading their file to their local machine. You will need to create a custom header button and implement that functionality yourself. A good place to start for that would be the Action Button API

Cheers,
Dustin

Thx for the reply

I am talking about the server side, not the client providing their own PDF.

Range requests are supported by the server, but somehow pdfjs express does not execute them (it downloads the whole file in one go). I tested by swapping pdfjs-express on our web app and replacing it with PDFTron, and that one does perform range requests.

Does pdfjs.express support range requests, or is this feature reserved for the paid versions of the libraries? I am using “@pdftron/pdfjs-express-viewer”: “8.1.1”. Thx

Found the issue. PDFJS express viewer 8.1.1 does support Range requests.

The reason why this was not working for us was that the PDF is hosted in another domain (CORS scenario), and we need to expose response headers. I tried exposing “Content-Range”, but that did not do the trick. Exposing * did solve the issue, now I can see 206 responses coming back.

Obviously, exposing * is not ideal, so if someone could provide some light about which response headers must be exposed in the CORS policy (besides Content-Range), that would be great. Thx

Hey there,

The only header you need to expose for CORS is:

Access-Control-Allow-Origin

Logan