UNPKG

mupdf-webviewer

Version:

The web viewer SDK using mupdf.js

72 lines (61 loc) 2.91 kB
# MuPDF WebViewer **A customizable PDF Viewer Component for the Web.** **MuPDF WebViewer** is an easy to use drop-in UI component for web pages which allows for in-context PDF viewing, data extraction, customization and more. ## Quick links - Docs: https://webviewer-docs.mupdf.com - Homepage: https://webviewer.mupdf.com - Samples: - Vanilla JS: https://github.com/ArtifexSoftware/mupdf-webviewer-vanilla-js-sample - React: https://github.com/ArtifexSoftware/mupdf-webviewer-react-sample - Vue: https://github.com/ArtifexSoftware/mupdf-webviewer-vue-sample - Angular: https://github.com/ArtifexSoftware/mupdf-webviewer-angular-sample - Changelog: https://webviewer-docs.mupdf.com/api-reference/changelog ## Installation ```bash npm install mupdf-webviewer ``` ## Quick start 1) Copy library assets ```bash cp -r node_modules/mupdf-webviewer/lib/* YOUR_LIBRARY_PATH/ ``` 2) Create DOM and initialize ```html <div id="viewer"></div> ``` ```js import { initMuPDFWebViewer } from 'mupdf-webviewer' initMuPDFWebViewer('#viewer', 'sample.pdf', { libraryPath: 'YOUR_LIBRARY_PATH', licenseKey: 'YOUR_LICENSE_KEY', }) .then(mupdf => { mupdf.toast.show({ type: 'success', content: 'Opened' }); }); ``` ## Common tasks - Save/Download: `await mupdf.document.export()`, `mupdf.document.download()` - Add a toolbar button: ```js mupdf.viewer.addButton({ buttons: [{ position: 'TOOLBAR.LEFT_SECTION.FIRST', icon: mupdf.refs.icon.ENTER_FULLSCREEN, label: 'Enter fullscreen', onclick: () => document.body.requestFullscreen(), }], }); ``` - Highlight vs PDF annotation: - `viewer.highlight`: screen overlay (not included in export/print/annotation API/capture) - `annotation.add(HIGHLIGHT)`: real PDF annotation (included in export/print/annotation API) ## API overview - [document](https://webviewer-docs.mupdf.com/api-reference/document), [viewer](https://webviewer-docs.mupdf.com/api-reference/viewer), [annotation](https://webviewer-docs.mupdf.com/api-reference/annotation), [redaction](https://webviewer-docs.mupdf.com/api-reference/redaction), [text](https://webviewer-docs.mupdf.com/api-reference/text), [watermark](https://webviewer-docs.mupdf.com/api-reference/watermark), [capture](https://webviewer-docs.mupdf.com/api-reference/capture), [toast](https://webviewer-docs.mupdf.com/api-reference/toast), [events](https://webviewer-docs.mupdf.com/api-reference/events) - See the [API Reference](https://webviewer-docs.mupdf.com/api-reference/introduction) in the docs for full APIs and parameters ## License - Free License (v0.6.0+): view-only (with restrictions) - Trial/Commercial: full features - Note: Free keys for v0.6.0 do not work on versions below 0.6.0 ## Support - Issues/Bugs: webviewer@artifex.com - FAQ/Guides: see the [WebViewer documentation](https://webviewer-docs.mupdf.com)