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

Setting chunk size by URL options #9782

Closed
T0mazz opened this issue Jun 6, 2018 · 1 comment
Closed

Setting chunk size by URL options #9782

T0mazz opened this issue Jun 6, 2018 · 1 comment

Comments

@T0mazz
Copy link

T0mazz commented Jun 6, 2018

Is there a way to configure chunk size by using the official pdf.js viewer (params after the ? or # in the URL) and without changing the source code ?

If not, is it planned to implement this functionality in a future pdf.js version ?

@Snuffleupagus
Copy link
Collaborator

First of all, as mentioned in multiple places the default viewer isn't intended to be used as-is without modification; see e.g. https://mozilla.github.io/pdf.js/getting_started/#introduction and https://github.com/mozilla/pdf.js/wiki/Setup-pdf.js-in-a-website#from-examples

Is there a way to configure chunk size by using the official pdf.js viewer (params after the ? or # in the URL) and without changing the source code ?

However there's a work-around available, as is explained in the FAQ; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#file. Hence it's possible to load the viewer without opening a PDF file, e.g. try https://mozilla.github.io/pdf.js/web/viewer.html?file= and then calling PDFViewerApplication.open(file, { rangeChunkSize: /* custom value here */, }); afterwards; please refer to the docs:

pdf.js/web/app.js

Lines 692 to 701 in 76337fd

/**
* Opens PDF document specified by URL or array with additional arguments.
* @param {string|TypedArray|ArrayBuffer} file - PDF location or binary data.
* @param {Object} args - (optional) Additional arguments for the getDocument
* call, e.g. HTTP headers ('httpHeaders') or
* alternative data transport ('range').
* @returns {Promise} - Returns the promise, which is resolved when document
* is opened.
*/
open(file, args) {

If not, is it planned to implement this functionality in a future pdf.js version ?

Allowing hash parameters to control various API options in this way has the potential to be a huge performance footgun, which is why it's purposely disabled in PR #4956. (The fact that it ever worked was a bug, and not a feature.)
Hence that's not something that should be implemented, besides as explained above a work-around is already available (if you don't want to change the code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants