pdfjs-dist - Unhandled rejection TypeError: pdfjs.getDocument is not a function at

123 views Asked by At

I'm having this problem. I'm using the pdfjs-dist to extract text from PDF in browser side. I followed some tutorials and code example in the internet but nothing works on my end.

So I have this code:

import * as pdfjs from 'pdfjs-dist';
// other functions
public async testing(pdfUrl: any) {  
    const loadingTask = pdfjs.getDocument(pdfUrl);  
    const doc = await loadingTask.promise;  
    const page = await doc.getPage(1);  
  
    return await page.getTextContent();  
}

Whenever I trigger this function I always end up in this error:

Unhandled rejection TypeError: pdfjs.getDocument is not a function at DataService.eval

Anyone knows what's wrong? Or am I missing out something?

0

There are 0 answers