DEV Community

artydev
artydev

Posted on

Loading pdf.js in node projects

I have struggled to import pdf.js in my project.

Here is what I have done to make it work :

npm install pdfjs-dist
Enter fullscreen mode Exit fullscreen mode

in Javascript file :

import * as pdfjsLib from "pdfjs-dist/legacy/build/pdf.mjs";

import * as workerURL from "pdfjs-dist/legacy/build/pdf.worker.min.mjs"

pdfjsLib.GlobalWorkerOptions.workerURL = workerURL;
Enter fullscreen mode Exit fullscreen mode

Hope this help

Top comments (0)