Skip to content

Commit e7c9f57

Browse files
committed
Update readme
1 parent 68de9eb commit e7c9f57

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pdfjs-viewer-element
22

3-
A custom element, based on [PDF.js default viewer](https://mozilla.github.io/pdf.js/web/viewer.html). Supported in all [major browsers](https://caniuse.com/custom-elementsv1) and works with most [JS frameworks](https://custom-elements-everywhere.com/). See [examples](https://alekswebnet.github.io/pdfjs-viewer-element/#demo) of usage in the different frameworks.
3+
A custom element, based on [PDF.js default viewer](https://mozilla.github.io/pdf.js/web/viewer.html). Supported in all [major browsers](https://caniuse.com/custom-elementsv1) and works with most [JS frameworks](https://custom-elements-everywhere.com/). See [examples](https://alekswebnet.github.io/pdfjs-viewer-element/#demo) of usage in Vue, React and Svelte or pure HTML.
44

55
⚠️ `pdfjs-viewer-element` requires PDF.js [prebuilt](http://mozilla.github.io/pdf.js/getting_started/), that includes the generic build of PDF.js and the viewer. To use the package you should [download](http://mozilla.github.io/pdf.js/getting_started/) and **place the prebuilt** files to some directory of your project. Then specify the path to this directory with `viewer-path` property (`/pdfjs` by default).
66

@@ -16,7 +16,7 @@ You have full access to PDF.js viewer application using `initialize` method.
1616

1717
[Getting started](https://alekswebnet.github.io/pdfjs-viewer-element/)
1818

19-
[Api](https://alekswebnet.github.io/pdfjs-viewer-element/#api)
19+
[API](https://alekswebnet.github.io/pdfjs-viewer-element/#api)
2020

2121
[Live examples](https://alekswebnet.github.io/pdfjs-viewer-element/#demo)
2222

@@ -74,12 +74,14 @@ For more clarity, see the [Api docs page](https://alekswebnet.github.io/pdfjs-vi
7474
`initialize` - using this method you can access PDFViewerApplication and use methods and events of PDF.js default viewer
7575

7676
```javascript
77-
document.addEventListener('DOMContentLoaded', async () => {
78-
const viewer = document.querySelector('pdfjs-viewer-element')
79-
// Wait for the viewer initialization, receive PDFViewerApplication
80-
const viewerApp = await viewer.initialize()
81-
// Open PDF file data using Uint8Array instead of URL
82-
viewerApp.open(pdfData)
77+
const viewer = document.querySelector('pdfjs-viewer-element')
78+
// Wait for the viewer initialization, receive PDFViewerApplication
79+
const viewerApp = await viewer.initialize()
80+
// Open PDF file data using Uint8Array instead of URL
81+
viewerApp.open(pdfData)
82+
// Use event bus to handle viewer application events
83+
viewerApp.eventBus.on('pagesloaded', () => {
84+
console.log('Viewer pages loaded')
8385
})
8486
```
8587

0 commit comments

Comments
 (0)