question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't enable progressive rendering (i.e. range-request download)

See original GitHub issue

Link to PDF file (or attach file here): out.pdf

Configuration:

  • Web browser and its version: Google Chrome 58.0.3029.110 (64-bit)
  • Operating system and its version: Debian GNU/Linux 9.0 (stretch)
  • PDF.js version: 1.8.188
  • Is an extension: no

PDFJS doesn’t initiate range request, just downloads the whole file, however, server have range request support:

curl -s -H "Range: bytes=500-1000" -D  - http://localhost:3000/api/files/7/preview/file.pdf -o /dev/null
HTTP/1.1 206 Partial Content
Connection: keep-alive
Set-Cookie: csrf-token=yaP9VNyKqYQ5Cs903x45WpiVhYvD8lbUX%2FtIQeG8ZrV1L%2Fq6LdI7ApKn7LFW9a%2F%2BuzGrmQSU3o8rB6c0;Path=/
Set-Cookie: ring-session=9PbMnYqfDK7frq%2BKLMjC3AOMGURDSm%2BNHhQy8voCTsdk4692%2FDJDhxm5oBm89prB%2FnSTVOnqSTItdC176rzdm%2BVNd2Ck3YX2xk9Bbi5%2FtJiPjGRzHk6ifsNfIwR5Nyi4ZnVhCa03tD%2FsUo6dVBjWlffiIGsS2x%2F836IXTMGM90mrz5PtRZLQIeaIED91Ehd64ip0MWhlAWBuFMDy4%2BVeog%3D%3D--pfr0sATxg5WkppYe2MKp4ih%2BUMNoXkMQIRPhRf6aUzk%3D;Path=/;HttpOnly;Max-Age=31536000
Content-Range: bytes 500-1000/2568004
Server: undertow
Content-Length: 501
Date: Fri, 19 May 2017 05:01:08 GMT

But in network console I see:

out.pdf	200	xhr	Other	2.4 MB

I’ve done linearization with qpdf --linearize

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zarkonecommented, Mar 23, 2018

Also, is it possible that you forgot to set Content-Range or Content-Length properly?

1reaction
zarkonecommented, Mar 23, 2018

hey @vickyatjoy, unfortunately not sure what is the reason in your case. It depends on your setup and could be something like apache\nginx proxy cuts the headers. But in my case NGINX proxy doesn’t cut anything by default.

Take a look at what headers it sends\returns on your local server. In my case it was (taken from chrome netwrok console):

[General]
Request URL:http://localhost:3000/api/files/428/preview/428.pdf
Request Method:GET
Status Code:206 Partial Content
Remote Address:[::1]:3000
Referrer Policy:no-referrer-when-downgrade

[Response Headers]
Accept-Ranges:bytes
Connection:keep-alive
Content-Length:65536
Content-Range:bytes 0-65535/498782
Date:Fri, 23 Mar 2018 07:43:46 GMT
Server:undertow
Set-Cookie:[ ... ]

[Request Headers]
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,da;q=0.6
Connection:keep-alive
Cookie: [ ... ]
Host:localhost:3000
Range:bytes=0-65535
Referer:http://localhost:3000/target/pdf.worker.min.js
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36
Read more comments on GitHub >

github_iconTop Results From Across the Web

Progressive loading - MuPDF
What is progressive loading? The idea of progressive loading is that as you download a PDF file into a browser, you can display...
Read more >
How to set range header from client with pdf.js? - Stack Overflow
The entire pdf file is getting downloaded in a single request. Now, I would like to do progressive loading (downloading by specifying the...
Read more >
Should I enable progressive download? - VEGAS Community
Progressive download option is used when you want to host your video on your web server. It simply moves a few mp4 headers...
Read more >
Optimize WebFont loading and rendering - web.dev
This post explains how to load WebFonts to prevent layout shifts and blank pages when WebFonts are not available when the page loads....
Read more >
Render Settings Explained - Quality vs. Render Time
Subdivs parameter for the Bucket or Progressive Image Sampler. If you can't get the desired quality, try decreasing the Noise Threshold ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found