# @dks9556/pdfjs-dist

> mirror of pdfjs-dist, bundled and exposed as ES module

Latest version **2.0.946** (published 2019-02-28) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @dks9556/pdfjs-dist
pnpm add @dks9556/pdfjs-dist
yarn add @dks9556/pdfjs-dist
bun add @dks9556/pdfjs-dist
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.946 |
| Published | 2019-02-28 |
| First published | 2019-02-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Rob Resendez |
| Maintainers | dks9556 |

## Links

- npm: https://www.npmjs.com/package/@dks9556/pdfjs-dist
- Repository: https://github.com/bundled-es-modules/pdfjs-dist
- Homepage: https://github.com/bundled-es-modules/pdfjs-dist#readme
- Issues: https://github.com/bundled-es-modules/pdfjs-dist/issues
- npm.io page: https://npm.io/package/@dks9556/pdfjs-dist

## Recent versions

- 2.0.946 (latest) — 2019-02-28
- 2.0.945 — 2019-02-27
- 2.0.944 — 2019-02-26
- 2.0.943 — 2019-02-26

## README

# pdfjs-dist

This is a mirror of [pdfjs-dist](https://www.npmjs.com/package/pdfjs-dist), bundled and exposed as an ES module

## Install

```bash
npm install @bundled-es-modules/pdfjs-dist
```

## Use

```js
import pdfjs from "@bundled-es-modules/pdfjs-dist/build/pdf";
import viewer from "@bundled-es-modules/pdfjs-dist/web/pdf_viewer";

pdfjs.GlobalWorkerOptions.workerSrc =
  "@bundled-es-modules/pdfjs-dist/pdf.worker.js";

var url = "basicapi.pdf";
var loadingTask = pdfjs.getDocument(url);
//...
```

**Important**: Unlike in the original build, the `pdfjs.GlobalWorkerOptions.workerSrc` is mandatory.

# Overview

### Structure

```
├── build/
│   ├── pdf.js                    - display layer
│   └── pdf.worker.js             - core layer
└── web/
    ├── pdf_viewer.js             - top-level viewer import, containing all necessary setup
    ├── module.js                 - pdf-viewer module, transformed from UMD to ESM
    └── util.js                   - utility module for setup
```

### Background

PDFJS is a library by Mozilla, created to facillitate client-side rendering of PDF documents.

Currently, the primary build for this project is provided as UMD-style modules at [pdfjs/pdfjs-dist](https://github.com/mozilla/pdfjs-dist).

_Support for es modules in the main project has been requested [here (#10317)](https://github.com/mozilla/pdf.js/issues/10317)_

### Rollup configuration

##### pdf.js

- Transform UMD to ESM
- Resolve commonJS imports, **except**:
- Ignore `pdf.worker.js` import. This is very important, as it's conditionally required and is very large in size.
- Copy over all remaining files we wish to provide.

With `pdf.worker.js` ignored, pdfjs will expect a link to the file externally (see above)

##### pdf_viewer.js

- Transform UMD to ESM
- Resolve imports
- Ignore `pdf.js`. This is important, as we don't want to serve duplicates of pdfjs.

With `pdf.js` ignored, the viewer will expect to find a global pdfjs. This is circumvented by temporarily adding pdfjs to the global scope, and removed immediately after the viewer acquires a reference.

### Building

```bash
npm run build
```

---
_Source: https://npm.io/package/@dks9556/pdfjs-dist · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
