Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justinfagnani/pdf-viewer-element
A web component for displaying PDFs
https://github.com/justinfagnani/pdf-viewer-element
Last synced: about 2 months ago
JSON representation
A web component for displaying PDFs
- Host: GitHub
- URL: https://github.com/justinfagnani/pdf-viewer-element
- Owner: justinfagnani
- Created: 2019-09-01T21:55:23.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T01:42:42.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T07:38:09.165Z (3 months ago)
- Language: TypeScript
- Size: 2.17 MB
- Stars: 46
- Watchers: 6
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ``
`` is a custom HTML element that displays PDFs, much like an `` tag.
`` is a drop-in PDF viewer. It works in plain HTML documents, and in frameworks with declararive templating like React, Vue, Angular, Lit, or Svelte.
`` is built with [PDF.js](https://github.com/mozilla/pdf.js), which renders PDFs with JavaScript. PDF.js is maintained by Mozilla and powers Firefox's built-in PDF viewer.
## Install
```sh
npm i pdf-viewer-element
```## Use
```html
```
### Or from a CDN like unpkg.com:
```html
```
# Goals
* Simple drop-in PDF viewer with no configuration required
* No build steps required
* Works from a CDN
* Optional configuration for power-users:
* Exposes most useful pdf.js options
* Customization via DOM: CSS variables, slots, parts, etc.
* Adapt pdf.js to the DOM: ie, pipe events back through elements# Project Goals
Why make this?
* Learn pdf.js
* Create a useful framework-agnostic element for the web ecosystem
* Gain experience with tricky module, worker, and asynchronous timing issues within web component wrappers
* Convince pdf.js to distribute modules and web components directly?# TODO
* Controls replaceable via ``s
* Tests
* Pipe events from pdf.js event-bus into DOM elements
* Options: rotation, auto-size
* Use ResizeObserver for auto-size
* Use IntersectionObserver for laziness