A
A
Alexander Shipin2022-02-01 18:24:01
PDF
Alexander Shipin, 2022-02-01 18:24:01

How to properly integrate PDF.js into a Typescript project?

Good afternoon.
There is an application implemented in Typescript, React and Gulp.
Approximately two weeks ago it was decided to integrate a new "chip": Show PDF file.
All the answers to the question "How to display PDF" that are available on the Internet have a common denominator - PDF.js (by Mozilla).
Installed via npm, integrated the assembly of pdf.min.js and pdf.min.worker.js into Gulp, added the types folder from the npm package (for types). Made in the React component the integration of the solution from the official PDFjs documentation. The assembly is successful.
But, when initializing Componenta, which displays a PDF file, we encountered the problem that pdfjLib is undefined, and no matter how we try to solve this problem, the answer is the same.
How to properly integrate PDF.js into a Typescript project?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Turnaviotov, 2022-02-02
@foxmuldercp

At the beginning of the file where this module is called, the library must be imported.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question