Is there a way to preview a PDF as a canvas without importing pdfjs-dist into my project?
I have already used the command $yarn add pdfjs-dist
to install pdfjs-dist.
Do I need to include any additional imports?
import pdfjsLib from "pdfjs-dist/build/pdf"; //<-- This is where I am facing an issue.
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';
No errors show up at this point, but when I run it, the console displays:
Uncaught TypeError: Cannot read properties of undefined (reading 'GlobalWorkerOptions') . . .