Ardenexal
Ardenexal

Reputation: 543

Error: Unknown action from worker: ReaderHeadersReady when loading a PDF using PDF.js

This code was working perfectly fine yesterday but this morning I am getting this error

pdf.js:276 Uncaught Error: Unknown action from worker: ReaderHeadersReady
    at error (pdf.js:276)
    at MessageHandler.messageHandlerComObjOnMessage (pdf.js:1565)
    at MessageHandler.messageHandlerComObjOnMessage (pdf.js:1565)

pdf.js:276 Uncaught Error: Unknown action from worker: GetReader
    at error (pdf.js:276)
    at MessageHandler.messageHandlerComObjOnMessage (pdf.js:1565)

Code

  function render(file) {
        PDFJS.getDocument(file.path).then(function (pdf) {
            pdfDoc = pdf;
            totalPages = pdf.numPages;
            renderPage(pageNumber)
        }).catch(function (reason) {
            console.error(reason);
        });
    }

and i am using the worker from

PDFJS.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';

The version of pdf.js i am using is 1.7.225 which currently is the lastest stable version.

Does anyone know what is cause this error?

Upvotes: 3

Views: 2634

Answers (2)

async5
async5

Reputation: 2691

Use specific version of the worker

PDFJS.workerSrc = 'https://npmcdn.com/[email protected]/build/pdf.worker.js';

Upvotes: 9

I had the same issue (but locked at version 1.8.524) and solved it by upgrading to the latest version at the date: 1.8.593

Upvotes: 1

Related Questions