Error type: worker.load is not a function
<p>When I want to extract text from PDF or image files, I use vue.js and nuxt.js. But doesn't seem to work. I do not know why.
This is my first time asking, if you need more information please feel free to ask me. I was stuck with this error for 4 days T^T. I really need help. </p>
<p>I tried to fix this error. I just want to fix the bug. </p>
<p>
<pre class="brush:js;toolbar:false;">async parseFile() {
if (this.uploadedFile) {
const fileType = this.getFileType(this.uploadedFile.name);
if (fileType === "image") {
const worker = createWorker();
await worker.load();
await worker.loadLanguage("eng");
await worker.initialize("eng");
const {
data: { text },
} = await worker.recognize(this.uploadedFile);
console.log(text);
await worker.terminate();
} else if (fileType === "pdf") {
const fileReader = new FileReader();
fileReader.onload = async () => {
const typedArray = new Uint8Array(fileReader.result);
const pdf = await pdfjsLib.getDocument(typedArray).promise;
const numPages = pdf.numPages;
let pdfText = "";
for (let i = 1; i <= numPages; i ) {
const page = await pdf.getPage(i);
const content = await page.getTextContent();
const pageText = content.items.map((item) => item.str).join(" ");
pdfText = pageText "\n";
}
console.log(pdfText);
};
fileReader.readAsArrayBuffer(this.uploadedFile);
}</pre>
</p>