agentcooper / react-pdf-highlighter

Set of React components for PDF annotation

Home Page:https://agentcooper.github.io/react-pdf-highlighter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unlock `pdfjs-dist` library version

andrewmiroshnichenko opened this issue · comments

Thanks for the cool library!
We are using it extensively in our project, along with other one react-pdf

We noticed that both libraries use pdfjs-dist package, with locked version. And, because these versions aren't the same - we have pdfjs-dist included two times into our production bundle.

Can't pdfjs-dist version for react-pdf-highlighter be unlocked by the chance?

I've now encountered this same issue, however it is completely stopping PDFs from rendering using this library. The error handler returns the following error:

The API version "2.8.335" does not match the Worker version "2.4.456"."

Upon exploring the package-lock.json, I can see that 2.4.456 is the version of pdfjs-dist in the dependencies of react-pdf, and 2.8.335 is the dependency of react-pdf-highlighter

I think there are some issues with the current major version of pdfjs-dist. I would happily land a PR that makes it work with pdfjs-dist 3.

I did manage to work around this by putting the following in my package.json

"overrides": {
        "react-pdf": "5.7.0",
        "pdfjs-dist": "2.16.105"
    },

I'm not sure if it was the react-pdf or pdfjs-dist override or a combiantion of both which got me past my issue eventually.