• I have several PDFs on my page and noticed that they’re all fetched at once onload. This significantly hogs the network and affects rendering times too. Would it be possible to prevent all pdfs from being fetched unless the viewer attempts to view them please?

    Found this in the following discussion
    https://github.com/mozilla/pdf.js/issues/8897

    pdf.js/src/display/global.js
    /**
    * Disable pre-fetching of PDF file data. When range requests are enabled
    * PDF.js will automatically keep fetching more data even if it isn’t needed
    * to display the current page. This default behavior can be disabled.
    *
    * NOTE: It is also necessary to disable streaming, see above,
    * in order for disabling of pre-fetching to work correctly.
    * @var {boolean}
    */
    PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ?
    false : PDFJS.disableAutoFetch);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Thomas McMahon

    (@twistermc)

    I can add it to the backlog. I’m using the pre-built package from Mozilla so that code above doesn’t exist. But there may be other ways of doing this.

    Thread Starter ionious

    (@ionious)

    I’ve tried to change the default settings in viewer.js file but they don’t see to have any effect. Perhaps you could declare the global variables elsewhere or re-build your pdf plugin based on the original source code.

    Thanks for the interest.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable Pre-Fetching of multiple PDFs’ is closed to new replies.