I have a PDF.js file that works fine in Safari on my local server, but when I put it on a remote server, a goofy error is returned:
Warning: setting up a fake worker.
Unhandled rejection: error: INVALID_STATE_ERR: DOM 11 exception
It will also show this error on my local computer if I manage to open the developer console. Close the console, display the PDF in Safari; open the console and it no longer works.
The question arises: how are the developer tools and the remote server different from working on the local server? Is this still a range checking problem?
I have PDF.js to work! I have changed so many things, I don’t know which part I worked in. Here is a list of the things I did.
Added compatibility.js - changed the last function in it like this:
(function checkRangeRequests() { var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; if (!isSafari) { return; } document.addEventListener('DOMContentLoaded', function (e) { if (isSafari) { PDFJS.disableRange = true; } }); })();
The order of xhr.open() calls in pdf.js , so xhr.setRequestHeader() happens after xhr.open()
Removed all lines of 'use strict';
Added xhr.setRequestHeader("Cache-control", "no-cache"); after xhr.open on lines 37272 and 41262
Minified pdf.js and it all works all the time!
source share