xyz-vue-pdf 1.0.0
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/LICENSE +21 -0
- package/README.md +910 -0
- package/dist/3ce22e999d54bb9ca8150a59207f9d3e.cur +0 -0
- package/dist/demo.html +17 -0
- package/dist/ef50ac9e93aaebe3299791c79f277f8e.cur +0 -0
- package/dist/icons/main.css +1 -0
- package/dist/icons/main.js +1 -0
- package/dist/icons/pdf.eot +0 -0
- package/dist/icons/pdf.svg +208 -0
- package/dist/icons/pdf.ttf +0 -0
- package/dist/icons/pdf.woff +0 -0
- package/dist/icons/pdf.woff2 +0 -0
- package/dist/xyz-vue-pdf.common.js +30481 -0
- package/dist/xyz-vue-pdf.common.js.map +1 -0
- package/dist/xyz-vue-pdf.umd.js +30491 -0
- package/dist/xyz-vue-pdf.umd.js.map +1 -0
- package/dist/xyz-vue-pdf.umd.min.js +1302 -0
- package/dist/xyz-vue-pdf.umd.min.js.map +1 -0
- package/package.json +74 -0
- package/readme/algorithm of theme apply.drawio +1 -0
- package/readme/algorithm-of-theme-apply.jpg +0 -0
- package/readme/config-legend.jpg +0 -0
- package/readme/dialog-buttons.jpg +0 -0
- package/readme/dialog-separator.jpg +0 -0
- package/readme/error-more-info.jpg +0 -0
- package/readme/error-wrapper.jpg +0 -0
- package/readme/find-input-placeholder.jpg +0 -0
- package/readme/find-message.jpg +0 -0
- package/readme/find-results-count.jpg +0 -0
- package/readme/horizontal-separator.jpg +0 -0
- package/readme/loading-bar-color.jpg +0 -0
- package/readme/loading-bar-secondary-color.jpg +0 -0
- package/readme/not-found.jpg +0 -0
- package/readme/sample.png +0 -0
- package/readme/sidebar.jpg +0 -0
- package/readme/thumbnail-border.jpg +0 -0
- package/readme/toggleable-items.jpg +0 -0
- package/readme/toolbar-field.jpg +0 -0
- package/readme/vertical-separator.jpg +0 -0
- package/src/types/pdf-viewer.d.ts +12 -0
package/README.md
ADDED
|
@@ -0,0 +1,910 @@
|
|
|
1
|
+
VUEjs v2 PDF viewer based on Mozilla's PDFJS.
|
|
2
|
+
|
|
3
|
+
[](https://www.jsdelivr.com/package/npm/vue-pdf-app)
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/vue-pdf-app)
|
|
6
|
+
|
|
7
|
+
100% PDFJS functionality:
|
|
8
|
+
|
|
9
|
+
- zoom
|
|
10
|
+
- open
|
|
11
|
+
- print
|
|
12
|
+
- download
|
|
13
|
+
- rotate
|
|
14
|
+
- text selection
|
|
15
|
+
- search panel
|
|
16
|
+
- pdf document password
|
|
17
|
+
- thumbnail, outline, attachments, annotation layers
|
|
18
|
+
|
|
19
|
+
Easily localized configurable toolbar
|
|
20
|
+
|
|
21
|
+
<sup style="color: red">NEW</sup> Toolbar custom UI
|
|
22
|
+
|
|
23
|
+
Cross-browser support (including IE11)
|
|
24
|
+
|
|
25
|
+
Color customization (IE11 not supported)
|
|
26
|
+
|
|
27
|
+
Buttons icons customization
|
|
28
|
+
|
|
29
|
+
Light/dark themes
|
|
30
|
+
|
|
31
|
+
Built-in typescript support
|
|
32
|
+
|
|
33
|
+
UMD/Unpkg support:
|
|
34
|
+
|
|
35
|
+
| File | Size | Gzipped |
|
|
36
|
+
| ---------------------- | ---------------------------------- | ---------- |
|
|
37
|
+
| vue-pdf-app.umd.min.js | 1742.89 KiB | 478.86 KiB |
|
|
38
|
+
| vue-pdf-app.umd.js | 3115.59 KiB | 677.87 KiB |
|
|
39
|
+
| vue-pdf-app.common.js | 3115.12 KiB | 677.71 KiB |
|
|
40
|
+
| icons/main.css | 15 - 40 KiB (depends from browser) | |
|
|
41
|
+
|
|
42
|
+
# Example
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<template>
|
|
46
|
+
<!-- used `style="height: 100vh;"` because without it in the Firefox 89 and Chrome 91 (June 2021) the `vue-pdf-app` is not rendering on the page, just empty space without any errors (since `vue-pdf-app` does not have height and it is the top tag in the generated markup ) -->
|
|
47
|
+
<!-- or you can just wrap `vue-pdf-app` in <div> tag and set height for it via CSS (like in `Script tag (unpkg)` example below) -->
|
|
48
|
+
<vue-pdf-app style="height: 100vh;" pdf="https://file-examples-com.github.io/uploads/2017/10/file-example_PDF_1MB.pdf"></vue-pdf-app>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
import VuePdfApp from "vue-pdf-app";
|
|
53
|
+
// import this to use default icons for buttons
|
|
54
|
+
import "vue-pdf-app/dist/icons/main.css";
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
components: {
|
|
58
|
+
VuePdfApp
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
</script>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+
|
|
66
|
+
[Live demo](https://codesandbox.io/s/vue-2-vue-pdf-app-wz5kv)
|
|
67
|
+
|
|
68
|
+
[Live demo 2](https://codepen.io/sandanat/pen/xxVdgYM)
|
|
69
|
+
|
|
70
|
+
[Examples source code](https://github.com/sandanat/vue-pdf-app/tree/master/examples "Examples source code")
|
|
71
|
+
|
|
72
|
+
[FAQ](https://github.com/sandanat/vue-pdf-app/blob/master/FAQ.md)
|
|
73
|
+
|
|
74
|
+
# API
|
|
75
|
+
|
|
76
|
+
## :pdf
|
|
77
|
+
|
|
78
|
+
- Type: `string | null | ArrayBuffer | TypedArray`
|
|
79
|
+
- Required: `false`
|
|
80
|
+
- Usage:
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<vue-pdf-app pdf="https://example.com/sample.pdf" />
|
|
84
|
+
<vue-pdf-app :pdf="ArrayBuffer" />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## :title
|
|
88
|
+
|
|
89
|
+
- Description: `true` renames document title to pdf file name.
|
|
90
|
+
- Type: `boolean`
|
|
91
|
+
- Required: `false`
|
|
92
|
+
- Default: `false`
|
|
93
|
+
- Usage:
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<vue-pdf-app :title="true" />
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## :theme.sync
|
|
100
|
+
|
|
101
|
+
- Type: `"dark" | "light"`
|
|
102
|
+
- Required: `false`
|
|
103
|
+
- Usage:
|
|
104
|
+
|
|
105
|
+
```vue
|
|
106
|
+
<vue-pdf-app theme="dark" />
|
|
107
|
+
<vue-pdf-app :theme="theme" />
|
|
108
|
+
<vue-pdf-app :theme.sync="theme" />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## <sup style="color: red">new</sup> :fileName
|
|
112
|
+
|
|
113
|
+
- Description: when pdf is passed like an array buffer default download file name is `document.pdf`. Set this prop to override it.
|
|
114
|
+
- Type: `string`
|
|
115
|
+
- Required: `false`
|
|
116
|
+
- Usage:
|
|
117
|
+
|
|
118
|
+
```vue
|
|
119
|
+
<vue-pdf-app :pdf="ArrayBuffer" file-name="file name" />
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## <sup style="color: red">new</sup> :pageScale
|
|
123
|
+
|
|
124
|
+
- Description: default page scale.
|
|
125
|
+
- Type: `number | "page-actual"| "page-width"| "page-height"| "page-fit"| "auto"`
|
|
126
|
+
- Required: `false`
|
|
127
|
+
- Usage:
|
|
128
|
+
|
|
129
|
+
```vue
|
|
130
|
+
// 20%
|
|
131
|
+
<vue-pdf-app page-scale="20" />
|
|
132
|
+
<vue-pdf-app :page-scale="20" />
|
|
133
|
+
<vue-pdf-app :page-scale="page-actual" />
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## <sup style="color: red">new</sup> :pageNumber
|
|
137
|
+
|
|
138
|
+
- Description: pdfjs stores last viewed page of a file in `window.localStorage.getItem("pdfjs.history")`. Specify the prop to override it.
|
|
139
|
+
- Type: `number`
|
|
140
|
+
- Required: `false`
|
|
141
|
+
- Usage:
|
|
142
|
+
|
|
143
|
+
```vue
|
|
144
|
+
<vue-pdf-app :page-number="1" />
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## :config
|
|
148
|
+
|
|
149
|
+
- Description: toolbar configuration. Toolbar is available by default. Specify `false` for buttons or whole group of buttons to disable them.
|
|
150
|
+
- Type: `toolbar config (see below)`
|
|
151
|
+
- Required: `false`
|
|
152
|
+
- Default: `toolbar config`
|
|
153
|
+
- Usage:
|
|
154
|
+
|
|
155
|
+
```vue
|
|
156
|
+
<vue-pdf-app :config="config" />
|
|
157
|
+
|
|
158
|
+
<script>
|
|
159
|
+
export default {
|
|
160
|
+
data() {
|
|
161
|
+
return {
|
|
162
|
+
// disable "Previous page" button
|
|
163
|
+
config: {
|
|
164
|
+
toolbar: {
|
|
165
|
+
toolbarViewerLeft: {
|
|
166
|
+
previous: false
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// disable whole page navigation panel
|
|
172
|
+
config2: {
|
|
173
|
+
toolbar: {
|
|
174
|
+
toolbarViewerLeft: false
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
// disable whole panel
|
|
179
|
+
config3: {
|
|
180
|
+
toolbar: false
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
</script>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
<details>
|
|
189
|
+
<summary>Config specification</summary>
|
|
190
|
+
|
|
191
|
+

|
|
192
|
+
|
|
193
|
+
<code>
|
|
194
|
+
<pre>
|
|
195
|
+
{
|
|
196
|
+
sidebar: {
|
|
197
|
+
viewThumbnail: true,
|
|
198
|
+
viewOutline: true,
|
|
199
|
+
viewAttachments: true,
|
|
200
|
+
},
|
|
201
|
+
secondaryToolbar: {
|
|
202
|
+
secondaryPresentationMode: true,
|
|
203
|
+
secondaryOpenFile: true,
|
|
204
|
+
secondaryPrint: true,
|
|
205
|
+
secondaryDownload: true,
|
|
206
|
+
secondaryViewBookmark: true,
|
|
207
|
+
firstPage: true,
|
|
208
|
+
lastPage: true,
|
|
209
|
+
pageRotateCw: true,
|
|
210
|
+
pageRotateCcw: true,
|
|
211
|
+
cursorSelectTool: true,
|
|
212
|
+
cursorHandTool: true,
|
|
213
|
+
scrollVertical: true,
|
|
214
|
+
scrollHorizontal: true,
|
|
215
|
+
scrollWrapped: true,
|
|
216
|
+
spreadNone: true,
|
|
217
|
+
spreadOdd: true,
|
|
218
|
+
spreadEven: true,
|
|
219
|
+
documentProperties: true,
|
|
220
|
+
},
|
|
221
|
+
toolbar: {
|
|
222
|
+
toolbarViewerLeft: {
|
|
223
|
+
findbar: true,
|
|
224
|
+
previous: true,
|
|
225
|
+
next: true,
|
|
226
|
+
pageNumber: true,
|
|
227
|
+
},
|
|
228
|
+
toolbarViewerRight: {
|
|
229
|
+
presentationMode: true,
|
|
230
|
+
openFile: true,
|
|
231
|
+
print: true,
|
|
232
|
+
download: true,
|
|
233
|
+
viewBookmark: true,
|
|
234
|
+
},
|
|
235
|
+
toolbarViewerMiddle: {
|
|
236
|
+
zoomOut: true,
|
|
237
|
+
zoomIn: true,
|
|
238
|
+
scaleSelectContainer: true,
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
errorWrapper: true,
|
|
242
|
+
};
|
|
243
|
+
</pre>
|
|
244
|
+
</code>
|
|
245
|
+
</details>
|
|
246
|
+
|
|
247
|
+
## <sup style="color: red">new</sup> :id-config
|
|
248
|
+
|
|
249
|
+
- Description: If default toolbar UI doesn't suite you it is possible to build custom toolbar. The prop contains elements ID to which to bind functionality. If element ID is specified in this prop appropriate button will be hidden in a default toolbar. May not work with UI framework components. That is because pdfjs internally manages attributes specific to a certain HTML element (for instance pdfjs toggles `disabled` attribute of a button but it won't if a div is used instead of a button). So it is better to use native HTML element specified as recommended in ID config specification below. Four slots are specially designed to build custom toolbar (are situated near a pdf page): `viewer-header, viewer-prepend, viewer-append, viewer-footer` (refer slots API). It is also possible to use other slots or elements outside vue-pdf-app.
|
|
250
|
+
- Type: `ID config (see below)`
|
|
251
|
+
- Required: `false`
|
|
252
|
+
- Usage:
|
|
253
|
+
|
|
254
|
+
```vue
|
|
255
|
+
<template>
|
|
256
|
+
<div>
|
|
257
|
+
<button :id="idConfig.zoomOut" type="button">Zoom out</button>
|
|
258
|
+
<vue-pdf-app :id-config="idConfig">
|
|
259
|
+
<template #viewer-prepend>
|
|
260
|
+
<div class="viewer-prepend">
|
|
261
|
+
<button :id="idConfig.zoomIn" type="button">Zoom in</button>
|
|
262
|
+
</div>
|
|
263
|
+
</template>
|
|
264
|
+
</vue-pdf-app>
|
|
265
|
+
</div>
|
|
266
|
+
</template>
|
|
267
|
+
|
|
268
|
+
<script>
|
|
269
|
+
export default {
|
|
270
|
+
data() {
|
|
271
|
+
return {
|
|
272
|
+
idConfig: { zoomIn: "zoomInId", zoomOut: "zoomOutId" }
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
</script>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
<details>
|
|
280
|
+
<summary>ID config specification</summary>
|
|
281
|
+
<code>
|
|
282
|
+
<pre>
|
|
283
|
+
{
|
|
284
|
+
|
|
285
|
+
cursorHandTool?: string; // <button> is recommended
|
|
286
|
+
cursorSelectTool?: string; // <button> is recommended
|
|
287
|
+
documentProperties?: string; // <button> is recommended
|
|
288
|
+
download?: string; // <button> is recommended
|
|
289
|
+
findbar?: string; // <div> is recommended
|
|
290
|
+
findEntireWord?: string; // <input type="checkbox"> is recommended
|
|
291
|
+
findHighlightAll?: string; // <input type="checkbox"> is recommended
|
|
292
|
+
findMessage?: string; // <span> is recommended
|
|
293
|
+
findInput?: string; // <input type="text"> is recommended
|
|
294
|
+
findMatchCase?: string; // <input type="checkbox"> is recommended
|
|
295
|
+
findNext?: string; // <button> is recommended
|
|
296
|
+
findPrevious?: string; // <button> is recommended
|
|
297
|
+
findResultsCount?: string; // <span> is recommended
|
|
298
|
+
firstPage?: string; // <button> is recommended
|
|
299
|
+
lastPage?: string; // <button> is recommended
|
|
300
|
+
nextPage?: string; // <button> is recommended
|
|
301
|
+
numPages?: string; // total pages qty. <span> is recommended
|
|
302
|
+
openFile?: string; // <button> is recommended
|
|
303
|
+
pageNumber?: string; // input for page number. <input type="number"> is recommended
|
|
304
|
+
pageRotateCcw?: string; // <button> is recommended
|
|
305
|
+
pageRotateCw?: string; // <button> is recommended
|
|
306
|
+
presentationMode?: string; // <button> is recommended
|
|
307
|
+
previousPage?: string; // <button> is recommended
|
|
308
|
+
print?: string; // <button> is recommended
|
|
309
|
+
scrollHorizontal?: string; // <button> is recommended
|
|
310
|
+
scrollVertical?: string; // <button> is recommended
|
|
311
|
+
scrollWrapped?: string; // <button> is recommended
|
|
312
|
+
sidebarToggle?: string; // <button> is recommended
|
|
313
|
+
spreadEven?: string; // <button> is recommended
|
|
314
|
+
spreadNone?: string; // <button> is recommended
|
|
315
|
+
spreadOdd?: string; // <button> is recommended
|
|
316
|
+
toggleFindbar?: string; // <button> is recommended
|
|
317
|
+
viewAttachments?: string; // <button> is recommended
|
|
318
|
+
viewBookmark?: string; // <a> tag is recommended
|
|
319
|
+
viewOutline?: string; // <button> tag is recommended
|
|
320
|
+
viewThumbnail?: string; // <button> tag is recommended
|
|
321
|
+
zoomIn?: string; // <button> tag is recommended
|
|
322
|
+
zoomOut?: string; // <button> tag is recommended
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
</pre>
|
|
326
|
+
</code>
|
|
327
|
+
</details>
|
|
328
|
+
|
|
329
|
+
> ℹ️ Note that elements must be in HTML document by the time vue-pdf-app is mounting (use `v-show` instead of `v-if` directive if necessary). Otherwise an error occurs.
|
|
330
|
+
|
|
331
|
+
## @after-created(PDFViewerApplication)
|
|
332
|
+
|
|
333
|
+
- Description: emitted only once when Pdfjs library is binded to vue component. Can be used to set Pdfjs config before pdf document opening.
|
|
334
|
+
- Arguments:
|
|
335
|
+
- PDFViewerApplication - [pdf application](https://github.com/mozilla/pdf.js/blob/master/web/app.js#L198)
|
|
336
|
+
- Usage:
|
|
337
|
+
|
|
338
|
+
```vue
|
|
339
|
+
<vue-pdf-app @after-created="afterCreated" />
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## @open(PDFViewerApplication)
|
|
343
|
+
|
|
344
|
+
- Description: emitted when pdf is opened but pages are not rendered.
|
|
345
|
+
- Arguments:
|
|
346
|
+
- PDFViewerApplication - [pdf application](https://github.com/mozilla/pdf.js/blob/master/web/app.js#L198)
|
|
347
|
+
- Usage:
|
|
348
|
+
|
|
349
|
+
```vue
|
|
350
|
+
<vue-pdf-app @open="openHandler" />
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## @pages-rendered(PDFViewerApplication)
|
|
354
|
+
|
|
355
|
+
- Description: emitted when pdf document pages are rendered. Can be used to set default pages scale, for instance.
|
|
356
|
+
- Arguments:
|
|
357
|
+
- PDFViewerApplication - [pdf application](https://github.com/mozilla/pdf.js/blob/master/web/app.js#L198)
|
|
358
|
+
- Usage:
|
|
359
|
+
|
|
360
|
+
```vue
|
|
361
|
+
<vue-pdf-app @pages-rendered="pagesRendered" />
|
|
362
|
+
|
|
363
|
+
<script>
|
|
364
|
+
export default {
|
|
365
|
+
methods: {
|
|
366
|
+
pagesRendered(pdfApp) {
|
|
367
|
+
setTimeout(() => (pdfApp.pdfViewer.currentScaleValue = "page-height"));
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
</script>
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
> ℹ️ Events are triggered in the following order `after-created (once) => open => pages-rendered`
|
|
375
|
+
|
|
376
|
+
## Slots
|
|
377
|
+
|
|
378
|
+
### Slot names
|
|
379
|
+
|
|
380
|
+
- toolbar-left-prepend
|
|
381
|
+
- toolbar-left-append
|
|
382
|
+
- toolbar-middle-prepend
|
|
383
|
+
- toolbar-middle-append
|
|
384
|
+
- toolbar-right-prepend
|
|
385
|
+
- toolbar-right-append
|
|
386
|
+
- toolbar-sidebar-prepend
|
|
387
|
+
- toolbar-sidebar-append
|
|
388
|
+
- secondary-toolbar-prepend
|
|
389
|
+
- secondary-toolbar-append
|
|
390
|
+
- footer
|
|
391
|
+
- <sup style="color: red">NEW</sup> viewer-header: slot before `viewer-prepend` slot. Can be used to build custom toolbar.
|
|
392
|
+
- <sup style="color: red">NEW</sup> viewer-prepend: slot before `viewerContainer` div. Can be used to build custom toolbar.
|
|
393
|
+
- <sup style="color: red">NEW</sup> viewer-append: slot after `viewerContainer` div. Can be used to build custom toolbar.
|
|
394
|
+
- <sup style="color: red">NEW</sup> viewer-footer: slot after `viewer-append` slot. Can be used to build custom toolbar.
|
|
395
|
+
|
|
396
|
+
### Slot props
|
|
397
|
+
|
|
398
|
+
Each slot has props:
|
|
399
|
+
|
|
400
|
+
1. toggleTheme
|
|
401
|
+
|
|
402
|
+
Type: (): void.
|
|
403
|
+
|
|
404
|
+
Description: toggle theme handler
|
|
405
|
+
|
|
406
|
+
1. <sup style="color: red">NEW</sup> isSidebarHidden
|
|
407
|
+
|
|
408
|
+
Type: boolean
|
|
409
|
+
|
|
410
|
+
Description: state of a sidebar (visible or hidden). Can be used to manage visibility of custom Attachments, Outline and Thumbnail buttons
|
|
411
|
+
|
|
412
|
+
1. <sup style="color: red">NEW</sup> isFindbarHidden
|
|
413
|
+
|
|
414
|
+
Type: boolean
|
|
415
|
+
|
|
416
|
+
Description: state of a findbar (visible or hidden). Can be used to manage visibility of custom findbar
|
|
417
|
+
|
|
418
|
+
```vue
|
|
419
|
+
<vue-pdf-app>
|
|
420
|
+
<template #toolbar-left-prepend="{ toggleTheme }">
|
|
421
|
+
<button @click="toggleTheme" type="button">Toggle theme</button>
|
|
422
|
+
</template>
|
|
423
|
+
</vue-pdf-app>
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
# Color customization (IE11 not supported)
|
|
427
|
+
|
|
428
|
+
Colors of the pdf viewer are customized via custom css properties:
|
|
429
|
+
|
|
430
|
+
```html
|
|
431
|
+
<style>
|
|
432
|
+
/* for dark theme */
|
|
433
|
+
.pdf-app.dark {
|
|
434
|
+
--pdf-toolbar-color: black;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* for light theme */
|
|
438
|
+
.pdf-app.light {
|
|
439
|
+
--pdf-toolbar-color: white;
|
|
440
|
+
}
|
|
441
|
+
</style>
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
<details>
|
|
445
|
+
<summary>Custom css properties specification</summary>
|
|
446
|
+
<table>
|
|
447
|
+
<tr>
|
|
448
|
+
<th>Property</th>
|
|
449
|
+
<th>Applied to selectors</th>
|
|
450
|
+
<th>Description</th>
|
|
451
|
+
</tr>
|
|
452
|
+
<tr>
|
|
453
|
+
<td>--pdf-app-background-color</td>
|
|
454
|
+
<td>.pdf-app</td>
|
|
455
|
+
<td>Background color for root pdf container</td>
|
|
456
|
+
</tr>
|
|
457
|
+
<tr>
|
|
458
|
+
<td>--pdf-button-hover-font-color</td>
|
|
459
|
+
<td>
|
|
460
|
+
.pdf-app .toolbarButton:hover
|
|
461
|
+
<hr>
|
|
462
|
+
.pdf-app .toolbarButton:focus
|
|
463
|
+
<hr>
|
|
464
|
+
.pdf-app .dropdownToolbarButton:hover
|
|
465
|
+
<hr>
|
|
466
|
+
.pdf-app .secondaryToolbarButton:hover
|
|
467
|
+
<hr>
|
|
468
|
+
.pdf-app .secondaryToolbarButton:focus
|
|
469
|
+
<hr>
|
|
470
|
+
</td>
|
|
471
|
+
<td>Hover color for buttons of toolbar and secondary toolbar</td>
|
|
472
|
+
</tr>
|
|
473
|
+
<tr>
|
|
474
|
+
<td>--pdf-button-toggled-color</td>
|
|
475
|
+
<td>
|
|
476
|
+
.pdf-app .toolbarButton.toggled
|
|
477
|
+
<hr>
|
|
478
|
+
.pdf-app .splitToolbarButton.toggled > .toolbarButton.toggled
|
|
479
|
+
<hr>
|
|
480
|
+
.pdf-app .secondaryToolbarButton.toggled
|
|
481
|
+
<hr>
|
|
482
|
+
.pdf-app .outlineItemToggler:hover
|
|
483
|
+
<hr>
|
|
484
|
+
.pdf-app .outlineItemToggler:hover + a
|
|
485
|
+
<hr>
|
|
486
|
+
.pdf-app .outlineItemToggler:hover ~ .outlineItems
|
|
487
|
+
<hr>
|
|
488
|
+
.pdf-app .outlineItem > a:hover
|
|
489
|
+
<hr>
|
|
490
|
+
.pdf-app .attachmentsItem > button:hover
|
|
491
|
+
</td>
|
|
492
|
+
<td>
|
|
493
|
+
Background color for toggleable buttons when selected, outline items on hover, attachment items on hover
|
|
494
|
+
<img src="./readme/toggleable-items.jpg" alt="toggleable items">
|
|
495
|
+
</td>
|
|
496
|
+
</tr>
|
|
497
|
+
<tr>
|
|
498
|
+
<td>--pdf-dialog-button-color</td>
|
|
499
|
+
<td>.pdf-app .dialog .overlayButton</td>
|
|
500
|
+
<td>
|
|
501
|
+
<img src="./readme/dialog-buttons.jpg" alt="dialog buttons">
|
|
502
|
+
</td>
|
|
503
|
+
</tr>
|
|
504
|
+
<tr>
|
|
505
|
+
<td>--pdf-dialog-button-font-color</td>
|
|
506
|
+
<td>.pdf-app .dialog .overlayButton</td>
|
|
507
|
+
<td>
|
|
508
|
+
<img src="./readme/dialog-buttons.jpg" alt="dialog buttons">
|
|
509
|
+
</td>
|
|
510
|
+
</tr>
|
|
511
|
+
<tr>
|
|
512
|
+
<td>--pdf-error-more-info-color</td>
|
|
513
|
+
<td>.pdf-app #errorMoreInfo</td>
|
|
514
|
+
<td>
|
|
515
|
+
<img src="./readme/error-more-info.jpg" alt="error more info">
|
|
516
|
+
</td>
|
|
517
|
+
</tr>
|
|
518
|
+
<tr>
|
|
519
|
+
<td>--pdf-error-more-info-font-color</td>
|
|
520
|
+
<td>.pdf-app #errorMoreInfo</td>
|
|
521
|
+
<td>
|
|
522
|
+
<img src="./readme/error-more-info.jpg" alt="error more info">
|
|
523
|
+
</td>
|
|
524
|
+
</tr>
|
|
525
|
+
<tr>
|
|
526
|
+
<td>--pdf-error-wrapper-color</td>
|
|
527
|
+
<td>.pdf-app #errorWrapper</td>
|
|
528
|
+
<td>
|
|
529
|
+
<img src="./readme/error-wrapper.jpg" alt="error wrapper">
|
|
530
|
+
</td>
|
|
531
|
+
</tr>
|
|
532
|
+
<tr>
|
|
533
|
+
<td>--pdf-find-input-placeholder-font-color</td>
|
|
534
|
+
<td>.pdf-app #findInput::placeholder</td>
|
|
535
|
+
<td>
|
|
536
|
+
<img src="./readme/find-input-placeholder.jpg" alt="find input placeholder">
|
|
537
|
+
</td>
|
|
538
|
+
</tr>
|
|
539
|
+
<tr>
|
|
540
|
+
<td>--pdf-find-message-font-color</td>
|
|
541
|
+
<td>.pdf-app #findMsg</td>
|
|
542
|
+
<td>
|
|
543
|
+
<img src="./readme/find-message.jpg" alt="find message">
|
|
544
|
+
</td>
|
|
545
|
+
</tr>
|
|
546
|
+
<tr>
|
|
547
|
+
<td>--pdf-find-results-count-color</td>
|
|
548
|
+
<td>.pdf-app #findResultsCount</td>
|
|
549
|
+
<td>
|
|
550
|
+
<img src="./readme/find-results-count.jpg" alt="find results count">
|
|
551
|
+
</td>
|
|
552
|
+
</tr>
|
|
553
|
+
<tr>
|
|
554
|
+
<td>--pdf-find-results-count-font-color</td>
|
|
555
|
+
<td>.pdf-app #findResultsCount</td>
|
|
556
|
+
<td>
|
|
557
|
+
<img src="./readme/find-results-count.jpg" alt="find results count">
|
|
558
|
+
</td>
|
|
559
|
+
</tr>
|
|
560
|
+
<tr>
|
|
561
|
+
<td>--pdf-horizontal-toolbar-separator-color</td>
|
|
562
|
+
<td>.pdf-app .horizontalToolbarSeparator</td>
|
|
563
|
+
<td>
|
|
564
|
+
<img src="./readme/horizontal-separator.jpg" alt="horizontal separator">
|
|
565
|
+
</td>
|
|
566
|
+
</tr>
|
|
567
|
+
<tr>
|
|
568
|
+
<td>--pdf-input-color</td>
|
|
569
|
+
<td>.pdf-app .toolbarField</td>
|
|
570
|
+
<td>
|
|
571
|
+
<img src="./readme/toolbar-field.jpg" alt="toolbar field">
|
|
572
|
+
</td>
|
|
573
|
+
</tr>
|
|
574
|
+
<tr>
|
|
575
|
+
<td>--pdf-input-font-color</td>
|
|
576
|
+
<td>.pdf-app .toolbarField</td>
|
|
577
|
+
<td>
|
|
578
|
+
<img src="./readme/toolbar-field.jpg" alt="toolbar field">
|
|
579
|
+
</td>
|
|
580
|
+
</tr>
|
|
581
|
+
<tr>
|
|
582
|
+
<td>--pdf-loading-bar-color</td>
|
|
583
|
+
<td>.pdf-app #loadingBar .progress</td>
|
|
584
|
+
<td>
|
|
585
|
+
<img src="./readme/loading-bar-color.jpg" alt="loading bar color">
|
|
586
|
+
</td>
|
|
587
|
+
</tr>
|
|
588
|
+
<tr>
|
|
589
|
+
<td>--pdf-loading-bar-secondary-color</td>
|
|
590
|
+
<td>.pdf-app #loadingBar .progress.indeterminate .glimmer</td>
|
|
591
|
+
<td>
|
|
592
|
+
<img src="./readme/loading-bar-secondary-color.jpg" alt="loading bar secondary color">
|
|
593
|
+
</td>
|
|
594
|
+
</tr>
|
|
595
|
+
<tr>
|
|
596
|
+
<td>--pdf-not-found-color</td>
|
|
597
|
+
<td>.pdf-app #findInput.notFound</td>
|
|
598
|
+
<td>
|
|
599
|
+
<img src="./readme/not-found.jpg" alt="not found">
|
|
600
|
+
</td>
|
|
601
|
+
</tr>
|
|
602
|
+
<tr>
|
|
603
|
+
<td>--pdf-overlay-container-color</td>
|
|
604
|
+
<td>.pdf-app #overlayContainer</td>
|
|
605
|
+
<td>Background color for overlay container of dialogs</td>
|
|
606
|
+
</tr>
|
|
607
|
+
<tr>
|
|
608
|
+
<td>--pdf-overlay-container-dialog-color</td>
|
|
609
|
+
<td>.pdf-app #overlayContainer > .container > .dialog</td>
|
|
610
|
+
<td>
|
|
611
|
+
Background color for document properties, password, print dialogs
|
|
612
|
+
</td>
|
|
613
|
+
</tr>
|
|
614
|
+
<tr>
|
|
615
|
+
<td>--pdf-overlay-container-dialog-font-color</td>
|
|
616
|
+
<td>.pdf-app #overlayContainer > .container > .dialog</td>
|
|
617
|
+
<td>
|
|
618
|
+
Font color for document properties, password, print dialogs
|
|
619
|
+
</td>
|
|
620
|
+
</tr>
|
|
621
|
+
<tr>
|
|
622
|
+
<td>--pdf-overlay-container-dialog-separator-color</td>
|
|
623
|
+
<td>.pdf-app .dialog .separator</td>
|
|
624
|
+
<td>
|
|
625
|
+
<img src="./readme/dialog-separator.jpg" alt="dialog separator">
|
|
626
|
+
</td>
|
|
627
|
+
</tr>
|
|
628
|
+
<tr>
|
|
629
|
+
<td>--pdf-sidebar-content-color</td>
|
|
630
|
+
<td>.pdf-app #sidebarContent</td>
|
|
631
|
+
<td>
|
|
632
|
+
Background color for sidebar
|
|
633
|
+
</td>
|
|
634
|
+
</tr>
|
|
635
|
+
<tr>
|
|
636
|
+
<td>--pdf-split-toolbar-button-separator-color</td>
|
|
637
|
+
<td>
|
|
638
|
+
.pdf-app .splitToolbarButtonSeparator
|
|
639
|
+
<hr>
|
|
640
|
+
.pdf-app .verticalToolbarSeparator
|
|
641
|
+
</td>
|
|
642
|
+
<td>
|
|
643
|
+
<img src="./readme/vertical-separator.jpg" alt="vertical separator">
|
|
644
|
+
</td>
|
|
645
|
+
</tr>
|
|
646
|
+
<tr>
|
|
647
|
+
<td>--pdf-thumbnail-selection-ring-selected-color</td>
|
|
648
|
+
<td>.pdf-app .thumbnail.selected > .thumbnailSelectionRing</td>
|
|
649
|
+
<td>
|
|
650
|
+
Border color for selected thumbnail
|
|
651
|
+
<img src="./readme/thumbnail-border.jpg" alt="thumbnail border">
|
|
652
|
+
</td>
|
|
653
|
+
</tr>
|
|
654
|
+
<tr>
|
|
655
|
+
<td>--pdf-thumbnail-selection-ring-color</td>
|
|
656
|
+
<td>
|
|
657
|
+
.pdf-app a:focus > .thumbnail > .thumbnailSelectionRing
|
|
658
|
+
<hr>
|
|
659
|
+
.pdf-app .thumbnail:hover > .thumbnailSelectionRing
|
|
660
|
+
</td>
|
|
661
|
+
<td>
|
|
662
|
+
Border color for thumbnail on hover and focus
|
|
663
|
+
<img src="./readme/thumbnail-border.jpg" alt="thumbnail border">
|
|
664
|
+
</td>
|
|
665
|
+
</tr>
|
|
666
|
+
<tr>
|
|
667
|
+
<td>--pdf-toolbar-color</td>
|
|
668
|
+
<td>
|
|
669
|
+
.pdf-app #toolbarContainer
|
|
670
|
+
<hr>
|
|
671
|
+
.pdf-app .findbar
|
|
672
|
+
<hr>
|
|
673
|
+
.pdf-app .secondaryToolbar
|
|
674
|
+
<hr>
|
|
675
|
+
.pdf-app .doorHanger:after
|
|
676
|
+
<hr>
|
|
677
|
+
.pdf-app .doorHangerRight:after
|
|
678
|
+
<hr>
|
|
679
|
+
.pdf-app .dropdownToolbarButton > select
|
|
680
|
+
<hr>
|
|
681
|
+
.pdf-app .dropdownToolbarButton > select > option
|
|
682
|
+
</td>
|
|
683
|
+
<td>
|
|
684
|
+
Background color for toolbar, findbar, secondary toolbar, page scale dropdown
|
|
685
|
+
</td>
|
|
686
|
+
</tr>
|
|
687
|
+
<tr>
|
|
688
|
+
<td>--pdf-toolbar-font-color</td>
|
|
689
|
+
<td>
|
|
690
|
+
.pdf-app .toolbarButton
|
|
691
|
+
<hr>
|
|
692
|
+
.pdf-app .dropdownToolbarButton
|
|
693
|
+
<hr>
|
|
694
|
+
.pdf-app .secondaryToolbarButton
|
|
695
|
+
<hr>
|
|
696
|
+
.pdf-app .dropdownToolbarButton > select
|
|
697
|
+
<hr>
|
|
698
|
+
.pdf-app .toolbarLabel
|
|
699
|
+
<hr>
|
|
700
|
+
.pdf-app .outlineItem > a
|
|
701
|
+
<hr>
|
|
702
|
+
.pdf-app .attachmentsItem > button
|
|
703
|
+
</td>
|
|
704
|
+
<td>
|
|
705
|
+
Font color for toolbar, findbar, secondary toolbar, page scale dropdown, attachments name</td>
|
|
706
|
+
</tr>
|
|
707
|
+
<tr>
|
|
708
|
+
<td>--pdf-toolbar-sidebar-color</td>
|
|
709
|
+
<td>.pdf-app #toolbarSidebar</td>
|
|
710
|
+
<td>
|
|
711
|
+
<img src="./readme/sidebar.jpg" alt="sidebar">
|
|
712
|
+
</td>
|
|
713
|
+
</tr>
|
|
714
|
+
</table>
|
|
715
|
+
</details>
|
|
716
|
+
|
|
717
|
+
# Icons customization
|
|
718
|
+
|
|
719
|
+
To use default icons `import "vue-pdf-app/dist/icons/main.css";`.
|
|
720
|
+
|
|
721
|
+
To use custom icons you have to implement [icons.css](https://github.com/sandanat/vue-pdf-app/blob/master/src/sass/icons.scss):
|
|
722
|
+
|
|
723
|
+
```css
|
|
724
|
+
.vue-pdf-app-icon::before,
|
|
725
|
+
.vue-pdf-app-icon::after {
|
|
726
|
+
font-family: "your font family";
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
.vue-pdf-app-icon.zoom-out::before {
|
|
730
|
+
content: "icon code";
|
|
731
|
+
}
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
# Light/dark themes
|
|
735
|
+
|
|
736
|
+
<details>
|
|
737
|
+
<summary>Algorithm of theme apply</summary>
|
|
738
|
+
<img src="./readme/algorithm-of-theme-apply.jpg" alt="Algorithm of theme apply">
|
|
739
|
+
</details>
|
|
740
|
+
|
|
741
|
+
Toggle theme button is not implemented by default.
|
|
742
|
+
It's up to you to decide where to place it.
|
|
743
|
+
The button can be implemented with slots:
|
|
744
|
+
|
|
745
|
+
```vue
|
|
746
|
+
<vue-pdf-app>
|
|
747
|
+
<template #footer="{ toggleTheme }">
|
|
748
|
+
<button @click="toggleTheme" type="button">Toggle theme</button>
|
|
749
|
+
</template>
|
|
750
|
+
</vue-pdf-app>
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
# Localized panel
|
|
754
|
+
|
|
755
|
+
English is the default language for panel.
|
|
756
|
+
Use `<link rel="resource" type="application/l10n" href="path-to-localization-file">` in your html for localization.
|
|
757
|
+
See [localization file examples](https://github.com/mozilla/pdf.js/tree/master/l10n "file examples").
|
|
758
|
+
|
|
759
|
+
# Examples
|
|
760
|
+
|
|
761
|
+
## Script tag (unpkg)
|
|
762
|
+
|
|
763
|
+
```html
|
|
764
|
+
<!DOCTYPE html>
|
|
765
|
+
<html lang="en">
|
|
766
|
+
<head>
|
|
767
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
768
|
+
<meta charset="utf-8" />
|
|
769
|
+
<title>Vue-pdf-app demo</title>
|
|
770
|
+
<link
|
|
771
|
+
rel="stylesheet"
|
|
772
|
+
href="https://unpkg.com/vue-pdf-app@2.0.0/dist/icons/main.css"
|
|
773
|
+
/>
|
|
774
|
+
<script src="https://unpkg.com/vue"></script>
|
|
775
|
+
<script src="https://unpkg.com/vue-pdf-app@2.0.0"></script>
|
|
776
|
+
<style>
|
|
777
|
+
body,
|
|
778
|
+
html {
|
|
779
|
+
padding: 0;
|
|
780
|
+
margin: 0;
|
|
781
|
+
}
|
|
782
|
+
</style>
|
|
783
|
+
</head>
|
|
784
|
+
|
|
785
|
+
<body>
|
|
786
|
+
<div id="app" style="height: 100vh;">
|
|
787
|
+
<vue-pdf-app pdf="/sample.pdf"></vue-pdf-app>
|
|
788
|
+
</div>
|
|
789
|
+
<script>
|
|
790
|
+
new Vue({
|
|
791
|
+
components: {
|
|
792
|
+
VuePdfApp: window["vue-pdf-app"]
|
|
793
|
+
}
|
|
794
|
+
}).$mount("#app");
|
|
795
|
+
</script>
|
|
796
|
+
</body>
|
|
797
|
+
</html>
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
## Typescript
|
|
801
|
+
|
|
802
|
+
```vue
|
|
803
|
+
<template>
|
|
804
|
+
<div id="app">
|
|
805
|
+
<vue-pdf-app pdf="/sample.pdf"></vue-pdf-app>
|
|
806
|
+
</div>
|
|
807
|
+
</template>
|
|
808
|
+
|
|
809
|
+
<script lang="ts">
|
|
810
|
+
import "vue-pdf-app/dist/icons/main.css";
|
|
811
|
+
import VuePdfApp from "vue-pdf-app";
|
|
812
|
+
import { Component, Vue } from "vue-property-decorator";
|
|
813
|
+
|
|
814
|
+
@Component({
|
|
815
|
+
components: {
|
|
816
|
+
VuePdfApp
|
|
817
|
+
}
|
|
818
|
+
})
|
|
819
|
+
export default class App extends Vue {}
|
|
820
|
+
</script>
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
## Lazy loading
|
|
824
|
+
|
|
825
|
+
PDFJS is a huge package (see the library size table above).
|
|
826
|
+
So use lazy loading to split your bundle into small pieces.
|
|
827
|
+
|
|
828
|
+
```vue
|
|
829
|
+
<template>
|
|
830
|
+
<div id="app">
|
|
831
|
+
<vue-pdf-app></vue-pdf-app>
|
|
832
|
+
</div>
|
|
833
|
+
</template>
|
|
834
|
+
|
|
835
|
+
<script>
|
|
836
|
+
import "vue-pdf-app/dist/icons/main.css";
|
|
837
|
+
import Loader from "./components/Loader.vue";
|
|
838
|
+
|
|
839
|
+
export default {
|
|
840
|
+
name: "App",
|
|
841
|
+
components: {
|
|
842
|
+
"vue-pdf-app": () => ({
|
|
843
|
+
component: new Promise((res) => {
|
|
844
|
+
return setTimeout(
|
|
845
|
+
() => res(import(/* webpackChunkName: "pdf-viewer" */ "vue-pdf-app")),
|
|
846
|
+
4000
|
|
847
|
+
);
|
|
848
|
+
}),
|
|
849
|
+
loading: Loader
|
|
850
|
+
})
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
</script>
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
## PDFJS interaction
|
|
857
|
+
|
|
858
|
+
You can interact with pdfjs library when pdf is opened via `open` event.
|
|
859
|
+
|
|
860
|
+
```vue
|
|
861
|
+
<template>
|
|
862
|
+
<div id="app">
|
|
863
|
+
<div id="pdf-wrapper">
|
|
864
|
+
<vue-pdf-app pdf="/sample.pdf" @open="openHandler"></vue-pdf-app>
|
|
865
|
+
</div>
|
|
866
|
+
<div id="info">
|
|
867
|
+
<h1>PDF info:</h1>
|
|
868
|
+
<div v-for="item in info" :key="item.name">
|
|
869
|
+
<span>{{ item.name }}: {{ item.value }}</span>
|
|
870
|
+
<br />
|
|
871
|
+
</div>
|
|
872
|
+
</div>
|
|
873
|
+
</div>
|
|
874
|
+
</template>
|
|
875
|
+
|
|
876
|
+
<script>
|
|
877
|
+
import "vue-pdf-app/dist/icons/main.css";
|
|
878
|
+
import VuePdfApp from "vue-pdf-app";
|
|
879
|
+
|
|
880
|
+
export default {
|
|
881
|
+
name: "App",
|
|
882
|
+
components: {
|
|
883
|
+
VuePdfApp
|
|
884
|
+
},
|
|
885
|
+
data() {
|
|
886
|
+
return {
|
|
887
|
+
info: []
|
|
888
|
+
};
|
|
889
|
+
},
|
|
890
|
+
methods: {
|
|
891
|
+
async openHandler(pdfApp) {
|
|
892
|
+
this.info = [];
|
|
893
|
+
const info = await pdfApp.pdfDocument
|
|
894
|
+
.getMetadata()
|
|
895
|
+
.catch(console.error.bind(console));
|
|
896
|
+
|
|
897
|
+
if (!info) return;
|
|
898
|
+
const props = Object.keys(info.info);
|
|
899
|
+
props.forEach((prop) => {
|
|
900
|
+
const obj = {
|
|
901
|
+
name: prop,
|
|
902
|
+
value: info.info[prop]
|
|
903
|
+
};
|
|
904
|
+
this.info.push(obj);
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
</script>
|
|
910
|
+
```
|