You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Try to use pdfjs-dist in React components and fail
import pdfjsLib from 'pdfjs-dist';
...
readFunction() {
fileReader = new FileReader();
fileReader.onload = function() {
let arr = new Uint8Array(this.result);
pdfjsLib.getDocument({data: arr}).then(function(pdf) {
console.log(pdf.numPages);
});
}
fileReader.readAsArrayBuffer(file);
}
...
<input type='file' onChange={ e => this.readFunction(e.target.files[0]) } />
What is the expected behavior?
Able to read pdf.numPages?
What went wrong?
Warning: Setting up fake worker.
Uncaught SyntaxError: Unexpected token <
Uncaught (in promise) Error: Setting up fake worker failed: "Cannot read property 'WorkerMessageHandler' of undefined". at pdf.js:8893
I'm trying to read some text from the input PDF file, but am unable to do so. Is it something to do with setting the worker? Both pdfjsLib.PDFJS and pdfjsLib.GlobalWorkerOptions are undefined.
The text was updated successfully, but these errors were encountered:
Configuration:
Steps to reproduce the problem:
npm install pdfjs-dist
pdfjs-dist
in React components and failWhat is the expected behavior?
Able to read
pdf.numPages
?What went wrong?
I'm trying to read some text from the input PDF file, but am unable to do so. Is it something to do with setting the worker? Both
pdfjsLib.PDFJS
andpdfjsLib.GlobalWorkerOptions
are undefined.The text was updated successfully, but these errors were encountered: