Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@bundled-es-modules/pdfjs-dist

bundled-es-modules40.1kApache-2.03.6.172-alpha.1TypeScript support: included

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

readme

pdfjs-dist

This is a mirror of pdfjs-dist, bundled and exposed as an ES module

Install

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

Use

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/build/pdf.worker.js";

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

Important: Unlike in the original build, the pdfjs.GlobalWorkerOptions.workerSrc is mandatory. We recommend supplying the worker via CDN.

Overview

Structure

├── build/
│   ├── pdf.js                    - display layer
│   └── pdf.worker.js             - core layer
|── types/                        - typescript typings
└── 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.

Support for es modules in the main project has been requested here (#10317)

Building

npm i
npm run build

changelog

Changelog

v3.6.172-alpha.1

v2.16.106

  • Equivalent to v2.16.105, corrects a problem w/ that relase: the web/ folder is missing! The intent of this release is to not cause breakages for consumers who may start receiving the incorrectly-published v2.16.105 release. Oops!

v2.16.105

  • Accidentally published a bundle which was missing some files

v2.16.105-alpha.1

Changed

  • Rollup, Rollup Plugins
    • Dependencies
      • rollup v1.x.x => v3.x.x
      • @rollup/plugin-commonjs -- replaces:
        • rollup-plugin-commonjs
      • @rollup/plugin-node-resolve -- replaces:
        • rollup-plugin-node-resolve
      • rollup-plugin-polyfil-node -- replaces:
        • rollup-plugin-node-builtins
        • rollup-plugin-node-globals
    • Build, rollup.config.js changed as appropriate
  • Project type to module

Added

  • CHANGELOG.md
  • @web/dev-server added to serve demo (which was improved very slightly)

v2.5.207

Changed

v2.2.228

Changed

v2.1.266