Import pdf.js with typescript
See original GitHub issueAttach (recommended) or Link to PDF file here:
Configuration:
- Web browser and its version: NODE 10
- Operating system and its version: LINUX/DOCKER
- PDF.js version: pdfjs-dist 2.2.2
- Is a browser extension: NO
Steps to reproduce the problem:
- Install pdfjs-dist with:
npm install pdfjs-dist --save
- Install @types/pdfjs-dist with:
npm install @types/pdfjs-dist --save-dev
- Import pdfjs-dist in a
*.ts
file:import { PDFJS } from 'pdfjs-dist';
- Use
getDocument
fromPDFJS
:PDFJS.getDocument('my.pdf')
- execute the code and see the error: PDFJS is not defined
What is the expected behavior? PDFJS works on typescript
What went wrong? PDFJS can’t export correctly the lib on typescript
Link to a viewer: not disponible
Work around: Import PDFJS in this way
import { PDFJSStatic } from 'pdfjs-dist';
const PDFJS: PDFJSStatic = require('pdfjs-dist');
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
How to Build a TypeScript PDF Viewer with PDF.js - PSPDFKit
In this tutorial, we'll show how to build a TypeScript PDF viewer with PDF.js, one of the most popular open source libraries for...
Read more >How can I get TypeScript to load the PDF.js NPM module and ...
I'm trying to import PDF. JS into a TypeScript project. I'm using the DefinitelyTyped bindings for pdfjs-dist , installed via npm install @ ......
Read more >How to Build a PDF Viewer with TypeScript & PDF.js | PDFTron
In this article, we show how to create a PDF viewing app using PDF.js and TypeScript.
Read more >Typescript Pdfjs Testyy - StackBlitz
import * as pdfjsLib from 'pdfjs-dist';. // Write TypeScript code! const appDiv: HTMLElement = document. getElementById('app');. appDiv.innerHTML = `.
Read more >@types/pdfjs-dist - npm
Stub TypeScript definitions entry for pdfjs-dist, which provides its own types definitions. Latest version: 2.10.378, last published: a year ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does pdfjs provide it’s own Typescript types somewhere else?
@types/pdfjs-dist
should be maintained bymozilla/pdfjs-dist
and/ormozilla/pdf.js
contributors.Only this contributors know the code and the functions and can write the required interfaces.