pdfjs-viewer-element 2.6.4 → 2.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -8
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,13 +10,17 @@ Supported in all [major browsers](https://caniuse.com/custom-elementsv1), and wo
|
|
|
10
10
|
See [demo pages](https://github.com/alekswebnet/pdfjs-viewer-element/tree/master/demo) for various usecases.
|
|
11
11
|
See [live examples](https://alekswebnet.github.io/pdfjs-viewer-element/#demo) of usage with frameworks.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## How it works
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
**⚠️ This is an important part !!!**
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
**You should download and place the PDF.js prebuilt files in the project.**
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
`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.
|
|
20
|
+
|
|
21
|
+
The prebuilt comes with each PDF.js release. Supported all v4 and v3 [releases](https://github.com/mozilla/pdf.js/releases).
|
|
22
|
+
|
|
23
|
+
Then specify the path to the directory with the `viewer-path` property (`/pdfjs` by default) and PDF file URL with `src` property (should refer to the [same origin](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#can-i-load-a-pdf-from-another-server-cross-domain-request)).
|
|
20
24
|
|
|
21
25
|
## Status
|
|
22
26
|
|
|
@@ -60,7 +64,7 @@ Using browser:
|
|
|
60
64
|
## Usage
|
|
61
65
|
|
|
62
66
|
```html
|
|
63
|
-
<pdfjs-viewer-element src="/file.pdf" viewer-path="/pdfjs-4.
|
|
67
|
+
<pdfjs-viewer-element src="/file.pdf" viewer-path="/pdfjs-4.5.136-dist"></pdfjs-viewer-element>
|
|
64
68
|
```
|
|
65
69
|
|
|
66
70
|
## Attributes
|
|
@@ -100,7 +104,7 @@ Use `viewer-css-theme` attribute to set light or dark theme manually:
|
|
|
100
104
|
```html
|
|
101
105
|
<pdfjs-viewer-element
|
|
102
106
|
src="/file.pdf"
|
|
103
|
-
viewer-path="/pdfjs-4.
|
|
107
|
+
viewer-path="/pdfjs-4.5.136-dist"
|
|
104
108
|
viewer-css-theme="DARK">
|
|
105
109
|
</pdfjs-viewer-element>
|
|
106
110
|
```
|
|
@@ -112,7 +116,7 @@ You can add your own CSS rules to the viewer application using `viewer-extra-sty
|
|
|
112
116
|
```html
|
|
113
117
|
<pdfjs-viewer-element
|
|
114
118
|
src="/file.pdf"
|
|
115
|
-
viewer-path="/pdfjs-4.
|
|
119
|
+
viewer-path="/pdfjs-4.5.136-dist"
|
|
116
120
|
viewer-extra-styles="#toolbarViewerMiddle { display: none; }"
|
|
117
121
|
viewer-extra-styles-urls="['/demo/viewer-custom-theme.css']">
|
|
118
122
|
</pdfjs-viewer-element>
|
|
@@ -145,7 +149,7 @@ Build your own theme with viewer's custom variables and `viewer-extra-styles-url
|
|
|
145
149
|
`initialize` - using this method you can access PDFViewerApplication and use methods and events of PDF.js default viewer
|
|
146
150
|
|
|
147
151
|
```html
|
|
148
|
-
<pdfjs-viewer-element viewer-path="/pdfjs-4.
|
|
152
|
+
<pdfjs-viewer-element viewer-path="/pdfjs-4.5.136-dist"></pdfjs-viewer-element>
|
|
149
153
|
```
|
|
150
154
|
|
|
151
155
|
```javascript
|
|
@@ -156,5 +160,31 @@ const viewerApp = await viewer.initialize()
|
|
|
156
160
|
viewerApp.open({ data: pdfData })
|
|
157
161
|
```
|
|
158
162
|
|
|
163
|
+
## Server configuration
|
|
164
|
+
|
|
165
|
+
Since v4 PDF.js requires `.mjs` files support, make sure your server has it.
|
|
166
|
+
|
|
167
|
+
In case of `nginx` this may causes to errors, see https://github.com/mozilla/pdf.js/issues/17296
|
|
168
|
+
|
|
169
|
+
Add `.mjs` files support for `nginx` example:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
server {
|
|
173
|
+
# ...
|
|
174
|
+
|
|
175
|
+
location / {
|
|
176
|
+
root /usr/share/nginx/html;
|
|
177
|
+
index index.html;
|
|
178
|
+
|
|
179
|
+
location ~* \.mjs$ {
|
|
180
|
+
types {
|
|
181
|
+
text/javascript mjs;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
|
|
159
189
|
## License
|
|
160
190
|
[MIT](http://opensource.org/licenses/MIT)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfjs-viewer-element",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Oleksandr Shevchuk",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"types"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@awlsn/pdfjs-full": "^4.2.392",
|
|
33
34
|
"@types/node": "^18.19.31",
|
|
34
35
|
"@vitest/browser": "^1.5.0",
|
|
35
36
|
"jsdom": "^22.1.0",
|