Skip to content

Instantly share code, notes, and snippets.

@robrez
Created December 7, 2018 18:59
Show Gist options
  • Save robrez/ed40f048be3be8319bdfe04673f2eef7 to your computer and use it in GitHub Desktop.
Save robrez/ed40f048be3be8319bdfe04673f2eef7 to your computer and use it in GitHub Desktop.
pdfreadme

pdfjs-dist

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

Install

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

Use

<script type="module">
  import { pdfjs as pdfjsLib } from '@bundled-es-modules/pdfjs-dist/index.js';
  pdfjs.GlobalWorkerOptions.workerSrc = '@bundled-es-modules/pdfjs-dist/build/pdf.worker.js';
  var url = "basicapi.pdf";
  var loadingTask = pdfjsLib.getDocument(url);
  //...
</script>

Overview of this mirror repo

Rollup to bundle an es module out of pdf.js. The web worker, pdf.worker.js is copied as-is from the original repo.

Support for es modules has been requested here, #10317

Building

npm run build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment