Does pdfjs-dist can run with Typescript?

Viewed 37

I want to preview pdf as canvas but I can't import pdfjs-dist in my project.

I've already installed pdfjs-dist using $yarn add pdfjs-dist

Do I have to import anything else?

import pdfjsLib from "pdfjs-dist/build/pdf"; //<-- Here is the problem.

pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://mozilla.github.io/pdf.js/build/pdf.worker.js';
Could not find a declaration file for module 'pdfjs-dist/build/pdf'. 'd:/pdf-genarator/node_modules/pdfjs-dist/build/pdf.js' implicitly has an 'any' type.

If I remove ../build/pdf;

import pdfjsLib from "pdfjs-dist";

pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://mozilla.github.io/pdf.js/build/pdf.worker.js';

It doesn't show an error here but when I run this the console said

Uncaught TypeError: Cannot read properties of undefined (reading 'GlobalWorkerOptions') . . .
0 Answers
Related