pdfjs-vue3 0.1.10 → 0.2.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/dist/pdfjs-vue3.css +2 -0
- package/dist/pdfjs-vue3.es.js +329 -480
- package/dist/pdfjs-vue3.umd.js +1 -1
- package/package.json +13 -12
- package/types/PdfHost.vue.d.ts +52 -66
- package/types/types.d.ts +1 -2
- package/dist/style.css +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.pdf-text-layer{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light only;text-align:initial;opacity:1;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;caret-color:canvastext;z-index:0;line-height:1;position:absolute;inset:0;overflow:clip}.pdf-text-layer.highlighting{touch-action:none}.pdf-text-layer :is(span,br){color:#0000;white-space:pre;cursor:text;transform-origin:0 0;position:absolute}.pdf-text-layer{--min-font-size:1;--text-scale-factor:calc(var(--total-scale-factor) * var(--min-font-size));--min-font-size-inv:calc(1 / var(--min-font-size))}.pdf-text-layer>:not(.markedContent),.pdf-text-layer .markedContent span:not(.markedContent){z-index:1;--font-height:0;font-size:calc(var(--text-scale-factor) * var(--font-height));--scale-x:1;--rotate:0deg;transform:rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv))}.pdf-text-layer .markedContent{display:contents}.pdf-text-layer span[role=img]{-webkit-user-select:none;user-select:none;cursor:default}.pdf-text-layer .highlight{--highlight-bg-color:#b400aa40;--highlight-selected-bg-color:#00640040;--highlight-backdrop-filter:none;--highlight-selected-backdrop-filter:none}@media screen and (forced-colors:active){.pdf-text-layer .highlight{--highlight-bg-color:transparent;--highlight-selected-bg-color:transparent;--highlight-backdrop-filter:var(--hcm-highlight-filter);--highlight-selected-backdrop-filter:var(--hcm-highlight-selected-filter)}}.pdf-text-layer .highlight{background-color:var(--highlight-bg-color);-webkit-backdrop-filter:var(--highlight-backdrop-filter);backdrop-filter:var(--highlight-backdrop-filter);border-radius:4px;margin:-1px;padding:1px}.pdf-text-layer .highlight.appended{position:initial}.pdf-text-layer .highlight.begin{border-radius:4px 0 0 4px}.pdf-text-layer .highlight.end{border-radius:0 4px 4px 0}.pdf-text-layer .highlight.middle{border-radius:0}.pdf-text-layer .highlight.selected{background-color:var(--highlight-selected-bg-color);-webkit-backdrop-filter:var(--highlight-selected-backdrop-filter);backdrop-filter:var(--highlight-selected-backdrop-filter);scroll-margin-top:50px}.pdf-text-layer ::selection{background:#0000ff40;background:color-mix(in srgb, AccentColor, transparent 75%)}.pdf-text-layer br::selection{background:0 0}.pdf-text-layer .endOfContent{z-index:0;cursor:default;-webkit-user-select:none;user-select:none;display:block;position:absolute;inset:100% 0 0}.pdf-text-layer.selecting .endOfContent{top:0}.textLayerImages{-webkit-user-select:none;user-select:none;position:absolute;inset:0}.textLayerImages canvas{transform-origin:0 0;position:absolute}.pdf-page{flex-direction:column;margin:1rem auto;display:flex}.pdf-page-layout{filter:drop-shadow(0 1px 2px #0000001a)drop-shadow(0 1px 1px #0000000f);background:#fff;margin:auto;display:flex;position:relative}.pdf-page-number{text-align:center;line-height:1.5}.pdf-page-overlay{position:absolute;inset:0}.pdf-progress{text-align:center;padding:1rem}.pdf-host{touch-action:pan-x pan-y;background:#dcdcdc;height:100%;padding:1rem 0;overflow:auto}.pdf-host:focus{outline:none}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/pdfjs-vue3.es.js
CHANGED
|
@@ -1,485 +1,334 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, nextTick as s, onBeforeUnmount as c, onMounted as l, openBlock as u, ref as d, renderList as f, renderSlot as p, shallowRef as m, toDisplayString as h, toValue as g, unref as _, watch as v, withCtx as y } from "vue";
|
|
2
|
+
import { GlobalWorkerOptions as b, TextLayer as x, getDocument as S } from "pdfjs-dist";
|
|
3
|
+
//#region src/types.ts
|
|
4
|
+
var C = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e[e.Auto = 0] = "Auto", e[e.WidthFit = 1] = "WidthFit", e[e.PageFit = 2] = "PageFit", e[e.Custom = 3] = "Custom", e;
|
|
6
|
+
}({}), w = /* @__PURE__ */ o({
|
|
7
|
+
__name: "PdfPageText",
|
|
8
|
+
props: {
|
|
9
|
+
viewport: {},
|
|
10
|
+
page: {}
|
|
11
|
+
},
|
|
12
|
+
setup(e) {
|
|
13
|
+
let t = e, n = d(), r;
|
|
14
|
+
v(() => [t.viewport, t.page], () => {
|
|
15
|
+
a();
|
|
16
|
+
});
|
|
17
|
+
async function a() {
|
|
18
|
+
let e = n.value, i = t.viewport;
|
|
19
|
+
if (!(!e || !i)) {
|
|
20
|
+
for (r &&= (r.cancel(), void 0); e.firstChild;) e.removeChild(e.firstChild);
|
|
21
|
+
r = new x({
|
|
22
|
+
textContentSource: t.page.streamTextContent(),
|
|
23
|
+
container: e,
|
|
24
|
+
viewport: i
|
|
25
|
+
}), await r.render();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return l(() => {
|
|
29
|
+
a();
|
|
30
|
+
}), (e, t) => (u(), i("div", {
|
|
31
|
+
ref_key: "rootEl",
|
|
32
|
+
ref: n,
|
|
33
|
+
class: "pdf-text-layer"
|
|
34
|
+
}, null, 512));
|
|
35
|
+
}
|
|
36
|
+
}), T = { class: "pdf-page-layout" }, E = { class: "pdf-page-overlay" }, D = {
|
|
37
|
+
key: 0,
|
|
38
|
+
class: "pdf-page-number"
|
|
39
|
+
}, O = 1100, k = 96 / 72, A = /* @__PURE__ */ o({
|
|
40
|
+
__name: "PdfPage",
|
|
41
|
+
props: {
|
|
42
|
+
zoom: {},
|
|
43
|
+
zoomType: {},
|
|
44
|
+
hideText: { type: Boolean },
|
|
45
|
+
hideNumber: { type: Boolean },
|
|
46
|
+
viewport: {},
|
|
47
|
+
page: {},
|
|
48
|
+
observer: {}
|
|
49
|
+
},
|
|
50
|
+
emits: ["update:zoom"],
|
|
51
|
+
setup(e, { expose: o, emit: s }) {
|
|
52
|
+
let f = e, m = s, g = d(), _ = d(), y = d(!1);
|
|
53
|
+
o({
|
|
54
|
+
rootEl: _,
|
|
55
|
+
inViewport: y
|
|
56
|
+
});
|
|
57
|
+
let b = t(() => {
|
|
58
|
+
let { width: e, height: t } = f.page.getViewport({ scale: k }), { width: n, height: r } = f.viewport, i = 0, a = 1;
|
|
59
|
+
switch (f.zoomType) {
|
|
60
|
+
case C.Auto: return i = Math.min(n, O) - 40, a = i / e, k * a;
|
|
61
|
+
case C.WidthFit: return i = n - 40, a = i / e, k * a;
|
|
62
|
+
case C.PageFit: return n > r ? (a = r / t, k * a) : (i = n - 40, a = i / e, k * a);
|
|
63
|
+
}
|
|
64
|
+
return k * f.zoom;
|
|
65
|
+
}), x = t(() => b.value * (window?.devicePixelRatio || 1)), S = t(() => f.page.getViewport({ scale: b.value })), A = t(() => f.page.getViewport({ scale: x.value }));
|
|
66
|
+
v(b, (e) => {
|
|
67
|
+
let t = e / k;
|
|
68
|
+
Math.abs(t - f.zoom) > .05 && m("update:zoom", t);
|
|
69
|
+
}, { immediate: !0 });
|
|
70
|
+
let j;
|
|
71
|
+
function M() {
|
|
72
|
+
if (!f.page || !g.value) return;
|
|
73
|
+
let e = f.page, t = S.value, n = A.value, r = g.value;
|
|
74
|
+
r.width = Math.ceil(n.width), r.height = Math.ceil(n.height), r.style.width = Math.floor(t.width) + "px", r.style.height = Math.floor(t.height) + "px";
|
|
75
|
+
let i = _.value;
|
|
76
|
+
i && (i.style.width = r.style.width, i.style.height = r.style.height);
|
|
77
|
+
let a = r.getContext("2d");
|
|
78
|
+
if (!(!a || !y.value)) {
|
|
79
|
+
if (j) {
|
|
80
|
+
j.cancel();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
j = e.render({
|
|
84
|
+
canvas: r,
|
|
85
|
+
canvasContext: a,
|
|
86
|
+
viewport: A.value
|
|
87
|
+
}), j.promise.then(() => j = void 0).catch(() => {
|
|
88
|
+
j = void 0, M();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return v(() => [
|
|
93
|
+
f.page,
|
|
94
|
+
x.value,
|
|
95
|
+
y.value
|
|
96
|
+
], () => {
|
|
97
|
+
M();
|
|
98
|
+
}, { immediate: !0 }), l(() => {
|
|
99
|
+
M(), _.value && f.observer?.observe(_.value);
|
|
100
|
+
}), c(() => {
|
|
101
|
+
_.value && f.observer?.unobserve(_.value);
|
|
102
|
+
}), (t, o) => (u(), i("div", {
|
|
103
|
+
ref_key: "rootEl",
|
|
104
|
+
ref: _,
|
|
105
|
+
class: "pdf-page"
|
|
106
|
+
}, [a("div", T, [a("canvas", {
|
|
107
|
+
ref_key: "canvas",
|
|
108
|
+
ref: g
|
|
109
|
+
}, null, 512), a("div", E, [e.hideText ? r("", !0) : (u(), n(w, {
|
|
110
|
+
key: 0,
|
|
111
|
+
viewport: A.value,
|
|
112
|
+
page: e.page
|
|
113
|
+
}, null, 8, ["viewport", "page"])), p(t.$slots, "default", { displaySize: A.value })])]), e.hideNumber ? r("", !0) : (u(), i("div", D, h(e.page.pageNumber), 1))], 512));
|
|
114
|
+
}
|
|
115
|
+
}), j = {
|
|
116
|
+
key: 0,
|
|
117
|
+
class: "pdf-progress"
|
|
118
|
+
}, M = /* @__PURE__ */ o({
|
|
119
|
+
__name: "PdfDocument",
|
|
120
|
+
props: {
|
|
121
|
+
hideText: { type: Boolean },
|
|
122
|
+
hideNumber: { type: Boolean },
|
|
123
|
+
zoomType: {},
|
|
124
|
+
zoom: {},
|
|
125
|
+
viewport: {},
|
|
126
|
+
src: {}
|
|
127
|
+
},
|
|
128
|
+
emits: ["error", "update:zoom"],
|
|
129
|
+
setup(t, { emit: a }) {
|
|
130
|
+
let o = t, s = a, g = m(), _ = m([]), b = m(), x = d(), C = [], w = d(!1), T = d(0);
|
|
131
|
+
function E(e) {
|
|
132
|
+
e && (C.push(e), C.length == 1 && (e.inViewport = !0));
|
|
133
|
+
}
|
|
134
|
+
function D() {
|
|
135
|
+
_.value.forEach((e) => e.cleanup()), _.value = [];
|
|
136
|
+
let e = g.value;
|
|
137
|
+
e && (e.destroy(), g.value = void 0), C = [];
|
|
138
|
+
}
|
|
139
|
+
return v(() => o.src, (e) => {
|
|
140
|
+
if (D(), !e) return;
|
|
141
|
+
let t = S(e);
|
|
142
|
+
w.value = !0, t.onProgress = (e) => {
|
|
143
|
+
e.total && (T.value = e.loaded / e.total);
|
|
144
|
+
}, t.promise.then((e) => {
|
|
145
|
+
g.value = e;
|
|
146
|
+
let t = [];
|
|
147
|
+
for (let n = 1; n <= e.numPages; n++) t.push(e.getPage(n));
|
|
148
|
+
Promise.all(t).then((t) => {
|
|
149
|
+
e === g.value && (_.value = t);
|
|
150
|
+
});
|
|
151
|
+
}).catch((e) => {
|
|
152
|
+
s("error", e);
|
|
153
|
+
}).finally(() => {
|
|
154
|
+
w.value = !1;
|
|
155
|
+
});
|
|
156
|
+
}, { immediate: !0 }), l(() => {
|
|
157
|
+
b.value = new IntersectionObserver((e) => {
|
|
158
|
+
e.forEach((e) => {
|
|
159
|
+
let t = C.find((t) => t?.rootEl === e.target);
|
|
160
|
+
t && (t.inViewport = e.isIntersecting);
|
|
161
|
+
});
|
|
162
|
+
}, { rootMargin: "0px" });
|
|
163
|
+
}), c(() => {
|
|
164
|
+
D(), b.value?.disconnect();
|
|
165
|
+
}), (a, c) => (u(), i("div", {
|
|
166
|
+
ref_key: "rootEl",
|
|
167
|
+
ref: x
|
|
168
|
+
}, [p(a.$slots, "loading", {
|
|
169
|
+
src: o.src,
|
|
170
|
+
loading: w.value,
|
|
171
|
+
progress: T.value
|
|
172
|
+
}, () => [w.value ? (u(), i("p", j, "loading " + h(Math.ceil(100 * T.value)) + "%", 1)) : r("", !0)]), (u(!0), i(e, null, f(_.value, (e) => (u(), n(A, {
|
|
173
|
+
ref_for: !0,
|
|
174
|
+
ref: E,
|
|
175
|
+
key: e.pageNumber,
|
|
176
|
+
page: e,
|
|
177
|
+
"hide-number": t.hideNumber,
|
|
178
|
+
"hide-text": t.hideText,
|
|
179
|
+
"zoom-type": t.zoomType,
|
|
180
|
+
zoom: t.zoom,
|
|
181
|
+
"onUpdate:zoom": c[0] ||= (e) => s("update:zoom", e),
|
|
182
|
+
observer: b.value,
|
|
183
|
+
viewport: t.viewport
|
|
184
|
+
}, {
|
|
185
|
+
default: y(({ displaySize: t }) => [p(a.$slots, "default", {
|
|
186
|
+
doc: g.value,
|
|
187
|
+
page: e,
|
|
188
|
+
displaySize: t
|
|
189
|
+
})]),
|
|
190
|
+
_: 2
|
|
191
|
+
}, 1032, [
|
|
192
|
+
"page",
|
|
193
|
+
"hide-number",
|
|
194
|
+
"hide-text",
|
|
195
|
+
"zoom-type",
|
|
196
|
+
"zoom",
|
|
197
|
+
"observer",
|
|
198
|
+
"viewport"
|
|
199
|
+
]))), 128))], 512));
|
|
200
|
+
}
|
|
48
201
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
emits: ["update:zoom"],
|
|
64
|
-
setup(e, { expose: a, emit: u }) {
|
|
65
|
-
const r = e, c = P(), m = P(), v = P(!1);
|
|
66
|
-
a({ rootEl: m, inViewport: v });
|
|
67
|
-
const l = M(() => {
|
|
68
|
-
const { width: n, height: s } = r.page.getViewport({ scale: k }), { width: d, height: f } = r.viewport;
|
|
69
|
-
let t = 0, i = 1;
|
|
70
|
-
switch (r.zoomType) {
|
|
71
|
-
case S.Auto:
|
|
72
|
-
return t = Math.min(d, ve) - 40, i = t / n, k * i;
|
|
73
|
-
case S.WidthFit:
|
|
74
|
-
return t = d - 40, i = t / n, k * i;
|
|
75
|
-
case S.PageFit:
|
|
76
|
-
return d > f ? (i = f / s, k * i) : (t = d - 40, i = t / n, k * i);
|
|
77
|
-
}
|
|
78
|
-
return k * r.zoom;
|
|
79
|
-
}), h = M(() => l.value * ((window == null ? void 0 : window.devicePixelRatio) || 1)), y = M(() => r.page.getViewport({ scale: l.value })), w = M(() => r.page.getViewport({ scale: h.value }));
|
|
80
|
-
j(l, (n) => {
|
|
81
|
-
const s = n / k;
|
|
82
|
-
Math.abs(s - r.zoom) > 0.05 && u("update:zoom", s);
|
|
83
|
-
}, { immediate: !0 });
|
|
84
|
-
let g;
|
|
85
|
-
function o() {
|
|
86
|
-
if (!r.page || !c.value)
|
|
87
|
-
return;
|
|
88
|
-
const n = r.page, s = y.value, d = w.value, f = c.value;
|
|
89
|
-
f.width = Math.ceil(d.width), f.height = Math.ceil(d.height), f.style.width = Math.floor(s.width) + "px", f.style.height = Math.floor(s.height) + "px";
|
|
90
|
-
const t = m.value;
|
|
91
|
-
t && (t.style.width = f.style.width, t.style.height = f.style.height);
|
|
92
|
-
const i = f.getContext("2d");
|
|
93
|
-
if (!i || !v.value)
|
|
94
|
-
return;
|
|
95
|
-
if (g) {
|
|
96
|
-
g.cancel();
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
console.debug(`rendering page ${n.pageNumber}`);
|
|
100
|
-
const b = {
|
|
101
|
-
canvasContext: i,
|
|
102
|
-
viewport: w.value
|
|
103
|
-
};
|
|
104
|
-
g = n.render(b), g.promise.then(() => g = void 0).catch(() => {
|
|
105
|
-
g = void 0, o();
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return j(() => [r.page, h.value, v.value], () => {
|
|
109
|
-
o();
|
|
110
|
-
}, { immediate: !0 }), L(() => {
|
|
111
|
-
var n;
|
|
112
|
-
o(), m.value && ((n = r.observer) == null || n.observe(m.value));
|
|
113
|
-
}), G(() => {
|
|
114
|
-
var n;
|
|
115
|
-
m.value && ((n = r.observer) == null || n.unobserve(m.value));
|
|
116
|
-
}), (n, s) => (T(), $("div", {
|
|
117
|
-
ref_key: "rootEl",
|
|
118
|
-
ref: m,
|
|
119
|
-
class: "pdf-page"
|
|
120
|
-
}, [
|
|
121
|
-
W("div", de, [
|
|
122
|
-
W("canvas", {
|
|
123
|
-
ref_key: "canvas",
|
|
124
|
-
ref: c
|
|
125
|
-
}, null, 512),
|
|
126
|
-
W("div", fe, [
|
|
127
|
-
n.hideText ? F("", !0) : (T(), R(ce, {
|
|
128
|
-
key: 0,
|
|
129
|
-
viewport: w.value,
|
|
130
|
-
page: n.page
|
|
131
|
-
}, null, 8, ["viewport", "page"])),
|
|
132
|
-
E(n.$slots, "default", { displaySize: w.value })
|
|
133
|
-
])
|
|
134
|
-
]),
|
|
135
|
-
n.hideNumber ? F("", !0) : (T(), $("div", pe, Z(n.page.pageNumber), 1))
|
|
136
|
-
], 512));
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
const he = {
|
|
140
|
-
key: 0,
|
|
141
|
-
class: "pdf-progress"
|
|
142
|
-
}, ge = /* @__PURE__ */ N({
|
|
143
|
-
__name: "PdfDocument",
|
|
144
|
-
props: {
|
|
145
|
-
hideText: { type: Boolean },
|
|
146
|
-
hideNumber: { type: Boolean },
|
|
147
|
-
zoomType: {},
|
|
148
|
-
zoom: {},
|
|
149
|
-
viewport: {},
|
|
150
|
-
src: {}
|
|
151
|
-
},
|
|
152
|
-
emits: ["error", "update:zoom"],
|
|
153
|
-
setup(e, { emit: a }) {
|
|
154
|
-
const u = e, r = B(), c = B([]), m = B(), v = P();
|
|
155
|
-
let l = [];
|
|
156
|
-
const h = P(!1), y = P(0);
|
|
157
|
-
function w(o) {
|
|
158
|
-
o && (l.push(o), l.length == 1 && (o.inViewport = !0));
|
|
159
|
-
}
|
|
160
|
-
function g() {
|
|
161
|
-
c.value.forEach((n) => n.cleanup()), c.value = [];
|
|
162
|
-
const o = r.value;
|
|
163
|
-
o && (o.destroy(), r.value = void 0), l = [];
|
|
164
|
-
}
|
|
165
|
-
return j(() => u.src, (o) => {
|
|
166
|
-
if (g(), !o)
|
|
167
|
-
return;
|
|
168
|
-
const n = le(o);
|
|
169
|
-
h.value = !0, n.onProgress = (s) => {
|
|
170
|
-
s.total && (y.value = s.loaded / s.total);
|
|
171
|
-
}, n.promise.then((s) => {
|
|
172
|
-
r.value = s;
|
|
173
|
-
const d = [];
|
|
174
|
-
for (let f = 1; f <= s.numPages; f++)
|
|
175
|
-
d.push(s.getPage(f));
|
|
176
|
-
Promise.all(d).then((f) => {
|
|
177
|
-
s === r.value && (c.value = f);
|
|
178
|
-
});
|
|
179
|
-
}).catch((s) => {
|
|
180
|
-
a("error", s);
|
|
181
|
-
}).finally(() => {
|
|
182
|
-
h.value = !1;
|
|
183
|
-
});
|
|
184
|
-
}, { immediate: !0 }), L(() => {
|
|
185
|
-
m.value = new IntersectionObserver((o) => {
|
|
186
|
-
o.forEach((n) => {
|
|
187
|
-
const s = l.find((d) => (d == null ? void 0 : d.rootEl) === n.target);
|
|
188
|
-
s && (s.inViewport = n.isIntersecting);
|
|
189
|
-
});
|
|
190
|
-
}, {
|
|
191
|
-
// root: rootEl.value,
|
|
192
|
-
rootMargin: "0px"
|
|
193
|
-
});
|
|
194
|
-
}), G(() => {
|
|
195
|
-
var o;
|
|
196
|
-
g(), (o = m.value) == null || o.disconnect();
|
|
197
|
-
}), (o, n) => (T(), $("div", {
|
|
198
|
-
ref_key: "rootEl",
|
|
199
|
-
ref: v
|
|
200
|
-
}, [
|
|
201
|
-
E(o.$slots, "loading", {
|
|
202
|
-
src: u.src,
|
|
203
|
-
loading: h.value,
|
|
204
|
-
progress: y.value
|
|
205
|
-
}, () => [
|
|
206
|
-
h.value ? (T(), $("p", he, "loading " + Z(Math.ceil(100 * y.value)) + "%", 1)) : F("", !0)
|
|
207
|
-
]),
|
|
208
|
-
(T(!0), $(ee, null, te(c.value, (s) => (T(), R(me, {
|
|
209
|
-
ref_for: !0,
|
|
210
|
-
ref: w,
|
|
211
|
-
key: s.pageNumber,
|
|
212
|
-
page: s,
|
|
213
|
-
"hide-number": o.hideNumber,
|
|
214
|
-
"hide-text": o.hideText,
|
|
215
|
-
"zoom-type": o.zoomType,
|
|
216
|
-
zoom: o.zoom,
|
|
217
|
-
"onUpdate:zoom": n[0] || (n[0] = (d) => a("update:zoom", d)),
|
|
218
|
-
observer: m.value,
|
|
219
|
-
viewport: o.viewport
|
|
220
|
-
}, {
|
|
221
|
-
default: A(({ displaySize: d }) => [
|
|
222
|
-
E(o.$slots, "default", {
|
|
223
|
-
doc: r.value,
|
|
224
|
-
page: s,
|
|
225
|
-
displaySize: d
|
|
226
|
-
})
|
|
227
|
-
]),
|
|
228
|
-
_: 2
|
|
229
|
-
}, 1032, ["page", "hide-number", "hide-text", "zoom-type", "zoom", "observer", "viewport"]))), 128))
|
|
230
|
-
], 512));
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
var I = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
234
|
-
function be(e) {
|
|
235
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
236
|
-
}
|
|
237
|
-
function ye(e) {
|
|
238
|
-
var a = typeof e;
|
|
239
|
-
return e != null && (a == "object" || a == "function");
|
|
240
|
-
}
|
|
241
|
-
var oe = ye, we = typeof I == "object" && I && I.Object === Object && I, _e = we, Te = _e, Pe = typeof self == "object" && self && self.Object === Object && self, ze = Te || Pe || Function("return this")(), ne = ze, xe = ne, Se = function() {
|
|
242
|
-
return xe.Date.now();
|
|
243
|
-
}, $e = Se, ke = /\s/;
|
|
244
|
-
function je(e) {
|
|
245
|
-
for (var a = e.length; a-- && ke.test(e.charAt(a)); )
|
|
246
|
-
;
|
|
247
|
-
return a;
|
|
248
|
-
}
|
|
249
|
-
var Ee = je, Oe = Ee, Ce = /^\s+/;
|
|
250
|
-
function Me(e) {
|
|
251
|
-
return e && e.slice(0, Oe(e) + 1).replace(Ce, "");
|
|
252
|
-
}
|
|
253
|
-
var Ie = Me, Ne = ne, Le = Ne.Symbol, re = Le, U = re, ie = Object.prototype, We = ie.hasOwnProperty, Be = ie.toString, C = U ? U.toStringTag : void 0;
|
|
254
|
-
function Ve(e) {
|
|
255
|
-
var a = We.call(e, C), u = e[C];
|
|
256
|
-
try {
|
|
257
|
-
e[C] = void 0;
|
|
258
|
-
var r = !0;
|
|
259
|
-
} catch {
|
|
260
|
-
}
|
|
261
|
-
var c = Be.call(e);
|
|
262
|
-
return r && (a ? e[C] = u : delete e[C]), c;
|
|
263
|
-
}
|
|
264
|
-
var De = Ve, Fe = Object.prototype, Ae = Fe.toString;
|
|
265
|
-
function Ge(e) {
|
|
266
|
-
return Ae.call(e);
|
|
267
|
-
}
|
|
268
|
-
var Re = Ge, K = re, He = De, Ue = Re, Ke = "[object Null]", Xe = "[object Undefined]", X = K ? K.toStringTag : void 0;
|
|
269
|
-
function Ye(e) {
|
|
270
|
-
return e == null ? e === void 0 ? Xe : Ke : X && X in Object(e) ? He(e) : Ue(e);
|
|
271
|
-
}
|
|
272
|
-
var qe = Ye;
|
|
273
|
-
function Je(e) {
|
|
274
|
-
return e != null && typeof e == "object";
|
|
275
|
-
}
|
|
276
|
-
var Qe = Je, Ze = qe, et = Qe, tt = "[object Symbol]";
|
|
277
|
-
function ot(e) {
|
|
278
|
-
return typeof e == "symbol" || et(e) && Ze(e) == tt;
|
|
202
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
203
|
+
var N = () => {};
|
|
204
|
+
function P(e, t) {
|
|
205
|
+
function n(...n) {
|
|
206
|
+
return new Promise((r, i) => {
|
|
207
|
+
Promise.resolve(e(() => t.apply(this, n), {
|
|
208
|
+
fn: t,
|
|
209
|
+
thisArg: this,
|
|
210
|
+
args: n
|
|
211
|
+
})).then(r).catch(i);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return n;
|
|
279
215
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return u || lt.test(e) ? ut(e.slice(2), u ? 2 : 8) : at.test(e) ? q : +e;
|
|
216
|
+
function F(e, t = {}) {
|
|
217
|
+
let n, r, i = N, a = (e) => {
|
|
218
|
+
clearTimeout(e), i(), i = N;
|
|
219
|
+
}, o;
|
|
220
|
+
return (s) => {
|
|
221
|
+
let c = g(e), l = g(t.maxWait);
|
|
222
|
+
return n && a(n), c <= 0 || l !== void 0 && l <= 0 ? (r &&= (a(r), void 0), Promise.resolve(s())) : new Promise((e, u) => {
|
|
223
|
+
i = t.rejectOnCancel ? u : e, o = s, l && !r && (r = setTimeout(() => {
|
|
224
|
+
n && a(n), r = void 0, e(o());
|
|
225
|
+
}, l)), n = setTimeout(() => {
|
|
226
|
+
r && a(r), r = void 0, e(s());
|
|
227
|
+
}, c);
|
|
228
|
+
});
|
|
229
|
+
};
|
|
295
230
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
var r, c, m, v, l, h, y = 0, w = !1, g = !1, o = !0;
|
|
299
|
-
if (typeof e != "function")
|
|
300
|
-
throw new TypeError(pt);
|
|
301
|
-
a = J(a) || 0, ft(u) && (w = !!u.leading, g = "maxWait" in u, m = g ? vt(J(u.maxWait) || 0, a) : m, o = "trailing" in u ? !!u.trailing : o);
|
|
302
|
-
function n(p) {
|
|
303
|
-
var x = r, O = c;
|
|
304
|
-
return r = c = void 0, y = p, v = e.apply(O, x), v;
|
|
305
|
-
}
|
|
306
|
-
function s(p) {
|
|
307
|
-
return y = p, l = setTimeout(t, a), w ? n(p) : v;
|
|
308
|
-
}
|
|
309
|
-
function d(p) {
|
|
310
|
-
var x = p - h, O = p - y, H = a - x;
|
|
311
|
-
return g ? mt(H, m - O) : H;
|
|
312
|
-
}
|
|
313
|
-
function f(p) {
|
|
314
|
-
var x = p - h, O = p - y;
|
|
315
|
-
return h === void 0 || x >= a || x < 0 || g && O >= m;
|
|
316
|
-
}
|
|
317
|
-
function t() {
|
|
318
|
-
var p = D();
|
|
319
|
-
if (f(p))
|
|
320
|
-
return i(p);
|
|
321
|
-
l = setTimeout(t, d(p));
|
|
322
|
-
}
|
|
323
|
-
function i(p) {
|
|
324
|
-
return l = void 0, o && r ? n(p) : (r = c = void 0, v);
|
|
325
|
-
}
|
|
326
|
-
function b() {
|
|
327
|
-
l !== void 0 && clearTimeout(l), y = 0, r = h = c = l = void 0;
|
|
328
|
-
}
|
|
329
|
-
function _() {
|
|
330
|
-
return l === void 0 ? v : i(D());
|
|
331
|
-
}
|
|
332
|
-
function z() {
|
|
333
|
-
var p = D(), x = f(p);
|
|
334
|
-
if (r = arguments, c = this, h = p, x) {
|
|
335
|
-
if (l === void 0)
|
|
336
|
-
return s(h);
|
|
337
|
-
if (g)
|
|
338
|
-
return clearTimeout(l), l = setTimeout(t, a), n(h);
|
|
339
|
-
}
|
|
340
|
-
return l === void 0 && (l = setTimeout(t, a)), v;
|
|
341
|
-
}
|
|
342
|
-
return z.cancel = b, z.flush = _, z;
|
|
231
|
+
function I(e, t = 200, n = {}) {
|
|
232
|
+
return P(F(t, n), e);
|
|
343
233
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
onPointerdown: s,
|
|
443
|
-
onPointermove: i[1] || (i[1] = //@ts-ignore
|
|
444
|
-
(...b) => V(d) && V(d)(...b)),
|
|
445
|
-
onPointerup: f,
|
|
446
|
-
onPointercancel: f,
|
|
447
|
-
onPointerleave: f,
|
|
448
|
-
onPointerout: f,
|
|
449
|
-
tabindex: "0",
|
|
450
|
-
class: "pdf-host"
|
|
451
|
-
}, [
|
|
452
|
-
(T(!0), $(ee, null, te(t.sources, (b) => (T(), R(ge, {
|
|
453
|
-
viewport: l.value,
|
|
454
|
-
src: b,
|
|
455
|
-
"hide-number": !!t.hideNumber,
|
|
456
|
-
"hide-text": !!t.hideText,
|
|
457
|
-
"zoom-type": t.zoomType || V(S).Auto,
|
|
458
|
-
zoom: t.zoom || 1,
|
|
459
|
-
"onUpdate:zoom": i[0] || (i[0] = (_) => u("update:zoom", _))
|
|
460
|
-
}, {
|
|
461
|
-
loading: A(({ loading: _, progress: z }) => [
|
|
462
|
-
E(t.$slots, "loading", {
|
|
463
|
-
source: b,
|
|
464
|
-
loading: _,
|
|
465
|
-
progress: z
|
|
466
|
-
})
|
|
467
|
-
]),
|
|
468
|
-
default: A(({ doc: _, page: z, displaySize: p }) => [
|
|
469
|
-
E(t.$slots, "page", {
|
|
470
|
-
source: b,
|
|
471
|
-
doc: _,
|
|
472
|
-
page: z,
|
|
473
|
-
displaySize: p
|
|
474
|
-
})
|
|
475
|
-
]),
|
|
476
|
-
_: 2
|
|
477
|
-
}, 1032, ["viewport", "src", "hide-number", "hide-text", "zoom-type", "zoom"]))), 256)),
|
|
478
|
-
E(t.$slots, "default")
|
|
479
|
-
], 544));
|
|
480
|
-
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/PdfHost.vue
|
|
236
|
+
var L = /* @__PURE__ */ o({
|
|
237
|
+
__name: "PdfHost",
|
|
238
|
+
props: {
|
|
239
|
+
workerSrc: {},
|
|
240
|
+
sources: {},
|
|
241
|
+
zoomType: {},
|
|
242
|
+
zoom: {},
|
|
243
|
+
hideText: { type: Boolean },
|
|
244
|
+
hideNumber: { type: Boolean }
|
|
245
|
+
},
|
|
246
|
+
emits: ["update:zoom", "update:zoomType"],
|
|
247
|
+
setup(t, { expose: r, emit: a }) {
|
|
248
|
+
let o = t, m = a, h = d();
|
|
249
|
+
r({
|
|
250
|
+
zoomIn: E,
|
|
251
|
+
zoomOut: D
|
|
252
|
+
}), v(() => o.workerSrc, (e) => {
|
|
253
|
+
e && (b.workerSrc = e);
|
|
254
|
+
}, { immediate: !0 });
|
|
255
|
+
function g(e) {
|
|
256
|
+
e.ctrlKey && (e.preventDefault(), e.deltaY < 0 ? E() : D());
|
|
257
|
+
}
|
|
258
|
+
function x(e) {
|
|
259
|
+
e.ctrlKey && (e.key === "0" || e.which == 48) && m("update:zoomType", C.Auto);
|
|
260
|
+
}
|
|
261
|
+
let S = d({
|
|
262
|
+
width: 0,
|
|
263
|
+
height: 0
|
|
264
|
+
}), w = I(() => {
|
|
265
|
+
let e = h.value;
|
|
266
|
+
e && (S.value = {
|
|
267
|
+
width: e.offsetWidth,
|
|
268
|
+
height: e.offsetHeight
|
|
269
|
+
});
|
|
270
|
+
}, 100);
|
|
271
|
+
function T(e) {
|
|
272
|
+
let t = e % .25;
|
|
273
|
+
return Number((e - t).toFixed(2));
|
|
274
|
+
}
|
|
275
|
+
function E() {
|
|
276
|
+
let e = T((o.zoom || 1) + .25);
|
|
277
|
+
m("update:zoom", Math.min(e, 2)), m("update:zoomType", C.Custom);
|
|
278
|
+
}
|
|
279
|
+
function D() {
|
|
280
|
+
let e = T((o.zoom || 1) - .25);
|
|
281
|
+
m("update:zoom", Math.max(e, .25)), m("update:zoomType", C.Custom);
|
|
282
|
+
}
|
|
283
|
+
return v(() => o.zoom, (e, t) => {
|
|
284
|
+
let n = h.value;
|
|
285
|
+
if (n && e && t) {
|
|
286
|
+
let r = n.scrollTop, i = n.scrollLeft, a = e / t;
|
|
287
|
+
s(() => {
|
|
288
|
+
n.scrollTop = r * a, n.scrollLeft = i * a;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}), l(() => {
|
|
292
|
+
window.addEventListener("resize", w), w();
|
|
293
|
+
}), c(() => {
|
|
294
|
+
window.removeEventListener("resize", w);
|
|
295
|
+
}), (r, a) => (u(), i("div", {
|
|
296
|
+
ref_key: "rootEl",
|
|
297
|
+
ref: h,
|
|
298
|
+
onWheel: g,
|
|
299
|
+
onKeydown: x,
|
|
300
|
+
tabindex: "0",
|
|
301
|
+
class: "pdf-host"
|
|
302
|
+
}, [(u(!0), i(e, null, f(t.sources, (e) => (u(), n(M, {
|
|
303
|
+
viewport: S.value,
|
|
304
|
+
src: e,
|
|
305
|
+
"hide-number": !!t.hideNumber,
|
|
306
|
+
"hide-text": !!t.hideText,
|
|
307
|
+
"zoom-type": t.zoomType || _(C).Auto,
|
|
308
|
+
zoom: t.zoom || 1,
|
|
309
|
+
"onUpdate:zoom": a[0] ||= (e) => m("update:zoom", e)
|
|
310
|
+
}, {
|
|
311
|
+
loading: y(({ loading: t, progress: n }) => [p(r.$slots, "loading", {
|
|
312
|
+
source: e,
|
|
313
|
+
loading: t,
|
|
314
|
+
progress: n
|
|
315
|
+
})]),
|
|
316
|
+
default: y(({ doc: t, page: n, displaySize: i }) => [p(r.$slots, "page", {
|
|
317
|
+
source: e,
|
|
318
|
+
doc: t,
|
|
319
|
+
page: n,
|
|
320
|
+
displaySize: i
|
|
321
|
+
})]),
|
|
322
|
+
_: 2
|
|
323
|
+
}, 1032, [
|
|
324
|
+
"viewport",
|
|
325
|
+
"src",
|
|
326
|
+
"hide-number",
|
|
327
|
+
"hide-text",
|
|
328
|
+
"zoom-type",
|
|
329
|
+
"zoom"
|
|
330
|
+
]))), 256)), p(r.$slots, "default")], 544));
|
|
331
|
+
}
|
|
481
332
|
});
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
S as ZoomType
|
|
485
|
-
};
|
|
333
|
+
//#endregion
|
|
334
|
+
export { L as PdfHost, C as ZoomType };
|
package/dist/pdfjs-vue3.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pdfjs-dist")):typeof define=="function"&&define.amd?define(["exports","vue","pdfjs-dist"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k.pdfjsVue3={},k.Vue,k.pdfjsLib))})(this,function(k,e,j){"use strict";var P=(t=>(t[t.Auto=0]="Auto",t[t.WidthFit=1]="WidthFit",t[t.PageFit=2]="PageFit",t[t.Custom=3]="Custom",t))(P||{});const U=e.defineComponent({__name:"PdfPageText",props:{viewport:{},page:{}},setup(t){const l=t,d=e.ref(),i=e.ref();e.watch(()=>l.page,async h=>{d.value=await h.getTextContent()},{immediate:!0}),e.watch(()=>[d.value,i.value,l.viewport],()=>{g()});let f;function g(){const h=i.value,c=d.value,b=l.viewport;if(!(!h||!c||!b)){if(f){f.cancel();return}for(;h.firstChild;)h.removeChild(h.firstChild);f=j.renderTextLayer({textContentSource:c,container:h,viewport:b}),f.promise.then(()=>{f=void 0}).catch(()=>{f=void 0}).finally(()=>{})}}return e.onMounted(()=>{g()}),(h,c)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:i,class:"pdf-text-layer"},null,512))}}),et="",H={class:"pdf-page-layout"},q={class:"pdf-page-overlay"},K={key:0,class:"pdf-page-number"},X=1100,x=96/72,Y=e.defineComponent({__name:"PdfPage",props:{zoom:{},zoomType:{},hideText:{type:Boolean},hideNumber:{type:Boolean},viewport:{},page:{},observer:{}},emits:["update:zoom"],setup(t,{expose:l,emit:d}){const i=t,f=e.ref(),g=e.ref(),h=e.ref(!1);l({rootEl:g,inViewport:h});const c=e.computed(()=>{const{width:r,height:s}=i.page.getViewport({scale:x}),{width:p,height:u}=i.viewport;let o=0,a=1;switch(i.zoomType){case P.Auto:return o=Math.min(p,X)-40,a=o/r,x*a;case P.WidthFit:return o=p-40,a=o/r,x*a;case P.PageFit:return p>u?(a=u/s,x*a):(o=p-40,a=o/r,x*a)}return x*i.zoom}),b=e.computed(()=>c.value*((window==null?void 0:window.devicePixelRatio)||1)),v=e.computed(()=>i.page.getViewport({scale:c.value})),T=e.computed(()=>i.page.getViewport({scale:b.value}));e.watch(c,r=>{const s=r/x;Math.abs(s-i.zoom)>.05&&d("update:zoom",s)},{immediate:!0});let y;function n(){if(!i.page||!f.value)return;const r=i.page,s=v.value,p=T.value,u=f.value;u.width=Math.ceil(p.width),u.height=Math.ceil(p.height),u.style.width=Math.floor(s.width)+"px",u.style.height=Math.floor(s.height)+"px";const o=g.value;o&&(o.style.width=u.style.width,o.style.height=u.style.height);const a=u.getContext("2d");if(!a||!h.value)return;if(y){y.cancel();return}console.debug(`rendering page ${r.pageNumber}`);const w={canvasContext:a,viewport:T.value};y=r.render(w),y.promise.then(()=>y=void 0).catch(()=>{y=void 0,n()})}return e.watch(()=>[i.page,b.value,h.value],()=>{n()},{immediate:!0}),e.onMounted(()=>{var r;n(),g.value&&((r=i.observer)==null||r.observe(g.value))}),e.onBeforeUnmount(()=>{var r;g.value&&((r=i.observer)==null||r.unobserve(g.value))}),(r,s)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:g,class:"pdf-page"},[e.createElementVNode("div",H,[e.createElementVNode("canvas",{ref_key:"canvas",ref:f},null,512),e.createElementVNode("div",q,[r.hideText?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(U,{key:0,viewport:T.value,page:r.page},null,8,["viewport","page"])),e.renderSlot(r.$slots,"default",{displaySize:T.value})])]),r.hideNumber?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",K,e.toDisplayString(r.page.pageNumber),1))],512))}}),tt="",J={key:0,class:"pdf-progress"},Q=e.defineComponent({__name:"PdfDocument",props:{hideText:{type:Boolean},hideNumber:{type:Boolean},zoomType:{},zoom:{},viewport:{},src:{}},emits:["error","update:zoom"],setup(t,{emit:l}){const d=t,i=e.shallowRef(),f=e.shallowRef([]),g=e.shallowRef(),h=e.ref();let c=[];const b=e.ref(!1),v=e.ref(0);function T(n){n&&(c.push(n),c.length==1&&(n.inViewport=!0))}function y(){f.value.forEach(r=>r.cleanup()),f.value=[];const n=i.value;n&&(n.destroy(),i.value=void 0),c=[]}return e.watch(()=>d.src,n=>{if(y(),!n)return;const r=j.getDocument(n);b.value=!0,r.onProgress=s=>{s.total&&(v.value=s.loaded/s.total)},r.promise.then(s=>{i.value=s;const p=[];for(let u=1;u<=s.numPages;u++)p.push(s.getPage(u));Promise.all(p).then(u=>{s===i.value&&(f.value=u)})}).catch(s=>{l("error",s)}).finally(()=>{b.value=!1})},{immediate:!0}),e.onMounted(()=>{g.value=new IntersectionObserver(n=>{n.forEach(r=>{const s=c.find(p=>(p==null?void 0:p.rootEl)===r.target);s&&(s.inViewport=r.isIntersecting)})},{rootMargin:"0px"})}),e.onBeforeUnmount(()=>{var n;y(),(n=g.value)==null||n.disconnect()}),(n,r)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:h},[e.renderSlot(n.$slots,"loading",{src:d.src,loading:b.value,progress:v.value},()=>[b.value?(e.openBlock(),e.createElementBlock("p",J,"loading "+e.toDisplayString(Math.ceil(100*v.value))+"%",1)):e.createCommentVNode("",!0)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,s=>(e.openBlock(),e.createBlock(Y,{ref_for:!0,ref:T,key:s.pageNumber,page:s,"hide-number":n.hideNumber,"hide-text":n.hideText,"zoom-type":n.zoomType,zoom:n.zoom,"onUpdate:zoom":r[0]||(r[0]=p=>l("update:zoom",p)),observer:g.value,viewport:n.viewport},{default:e.withCtx(({displaySize:p})=>[e.renderSlot(n.$slots,"default",{doc:i.value,page:s,displaySize:p})]),_:2},1032,["page","hide-number","hide-text","zoom-type","zoom","observer","viewport"]))),128))],512))}}),ot="";var $=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Z(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ee(t){var l=typeof t;return t!=null&&(l=="object"||l=="function")}var O=ee,te=typeof $=="object"&&$&&$.Object===Object&&$,oe=te,ne=oe,re=typeof self=="object"&&self&&self.Object===Object&&self,ie=ne||re||Function("return this")(),M=ie,ae=M,le=function(){return ae.Date.now()},se=le,ce=/\s/;function de(t){for(var l=t.length;l--&&ce.test(t.charAt(l)););return l}var fe=de,pe=fe,ue=/^\s+/;function me(t){return t&&t.slice(0,pe(t)+1).replace(ue,"")}var he=me,ge=M,be=ge.Symbol,N=be,I=N,V=Object.prototype,ye=V.hasOwnProperty,we=V.toString,E=I?I.toStringTag:void 0;function ve(t){var l=ye.call(t,E),d=t[E];try{t[E]=void 0;var i=!0}catch{}var f=we.call(t);return i&&(l?t[E]=d:delete t[E]),f}var Te=ve,_e=Object.prototype,ke=_e.toString;function Pe(t){return ke.call(t)}var ze=Pe,L=N,Se=Te,xe=ze,Ee="[object Null]",Be="[object Undefined]",W=L?L.toStringTag:void 0;function $e(t){return t==null?t===void 0?Be:Ee:W&&W in Object(t)?Se(t):xe(t)}var je=$e;function Ce(t){return t!=null&&typeof t=="object"}var Oe=Ce,Me=je,Ne=Oe,Ie="[object Symbol]";function Ve(t){return typeof t=="symbol"||Ne(t)&&Me(t)==Ie}var Le=Ve,We=he,F=O,Fe=Le,D=0/0,De=/^[-+]0x[0-9a-f]+$/i,Ae=/^0b[01]+$/i,Re=/^0o[0-7]+$/i,Ge=parseInt;function Ue(t){if(typeof t=="number")return t;if(Fe(t))return D;if(F(t)){var l=typeof t.valueOf=="function"?t.valueOf():t;t=F(l)?l+"":l}if(typeof t!="string")return t===0?t:+t;t=We(t);var d=Ae.test(t);return d||Re.test(t)?Ge(t.slice(2),d?2:8):De.test(t)?D:+t}var He=Ue,qe=O,C=se,A=He,Ke="Expected a function",Xe=Math.max,Ye=Math.min;function Je(t,l,d){var i,f,g,h,c,b,v=0,T=!1,y=!1,n=!0;if(typeof t!="function")throw new TypeError(Ke);l=A(l)||0,qe(d)&&(T=!!d.leading,y="maxWait"in d,g=y?Xe(A(d.maxWait)||0,l):g,n="trailing"in d?!!d.trailing:n);function r(m){var S=i,B=f;return i=f=void 0,v=m,h=t.apply(B,S),h}function s(m){return v=m,c=setTimeout(o,l),T?r(m):h}function p(m){var S=m-b,B=m-v,G=l-S;return y?Ye(G,g-B):G}function u(m){var S=m-b,B=m-v;return b===void 0||S>=l||S<0||y&&B>=g}function o(){var m=C();if(u(m))return a(m);c=setTimeout(o,p(m))}function a(m){return c=void 0,n&&i?r(m):(i=f=void 0,h)}function w(){c!==void 0&&clearTimeout(c),v=0,i=b=f=c=void 0}function _(){return c===void 0?h:a(C())}function z(){var m=C(),S=u(m);if(i=arguments,f=this,b=m,S){if(c===void 0)return s(b);if(y)return clearTimeout(c),c=setTimeout(o,l),r(b)}return c===void 0&&(c=setTimeout(o,l)),h}return z.cancel=w,z.flush=_,z}var Qe=Je;const R=Z(Qe),Ze=e.defineComponent({__name:"PdfHost",props:{workerSrc:{},sources:{},zoomType:{},zoom:{},hideText:{type:Boolean},hideNumber:{type:Boolean},enablePinchZoom:{type:Boolean}},emits:["update:zoom","update:zoomType"],setup(t,{expose:l,emit:d}){const i=t,f=e.ref();l({zoomIn:T,zoomOut:y}),e.watch(()=>i.workerSrc,o=>{o&&(j.GlobalWorkerOptions.workerSrc=o)},{immediate:!0});function g(o){o.ctrlKey&&(o.preventDefault(),o.deltaY<0?T():y())}function h(o){o.ctrlKey&&(o.key==="0"||o.which==48)&&d("update:zoomType",P.Auto)}const c=e.ref({width:0,height:0}),b=R(()=>{const o=f.value;o&&(c.value={width:o.offsetWidth,height:o.offsetHeight})},100);function v(o){const a=o%.25;return Number((o-a).toFixed(2))}function T(){const o=v((i.zoom||1)+.25);d("update:zoom",Math.min(o,2)),d("update:zoomType",P.Custom)}function y(){const o=v((i.zoom||1)-.25);d("update:zoom",Math.max(o,.25)),d("update:zoomType",P.Custom)}e.watch(()=>i.zoom,(o,a)=>{const w=f.value;if(w&&o&&a){const _=w.scrollTop,z=w.scrollLeft,m=o/a;e.nextTick(()=>{w.scrollTop=_*m,w.scrollLeft=z*m})}}),e.onMounted(()=>{window.addEventListener("resize",b),b()}),e.onBeforeUnmount(()=>{window.removeEventListener("resize",b)});const n=[];let r=-1;function s(o){i.enablePinchZoom&&n.push(o)}const p=R(o=>{if(i.enablePinchZoom){for(let a=0;a<n.length;a++)if(o.pointerId===n[a].pointerId){n[a]=o;break}if(n.length===2){const a=Math.abs(n[0].clientX-n[1].clientX),w=Math.abs(n[0].clientY-n[1].clientY),_=Math.sqrt(Math.pow(a,2)+Math.pow(w,2));r>0&&(_>r&&T(),_<r&&y()),r=_}}},10);function u(o){if(i.enablePinchZoom){for(let a=0;a<n.length;a++)if(n[a].pointerId===o.pointerId){n.splice(a,1);break}n.length<2&&(r=-1)}}return(o,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"rootEl",ref:f,onWheel:g,onKeydown:h,onPointerdown:s,onPointermove:a[1]||(a[1]=(...w)=>e.unref(p)&&e.unref(p)(...w)),onPointerup:u,onPointercancel:u,onPointerleave:u,onPointerout:u,tabindex:"0",class:"pdf-host"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.sources,w=>(e.openBlock(),e.createBlock(Q,{viewport:c.value,src:w,"hide-number":!!o.hideNumber,"hide-text":!!o.hideText,"zoom-type":o.zoomType||e.unref(P).Auto,zoom:o.zoom||1,"onUpdate:zoom":a[0]||(a[0]=_=>d("update:zoom",_))},{loading:e.withCtx(({loading:_,progress:z})=>[e.renderSlot(o.$slots,"loading",{source:w,loading:_,progress:z})]),default:e.withCtx(({doc:_,page:z,displaySize:m})=>[e.renderSlot(o.$slots,"page",{source:w,doc:_,page:z,displaySize:m})]),_:2},1032,["viewport","src","hide-number","hide-text","zoom-type","zoom"]))),256)),e.renderSlot(o.$slots,"default")],544))}}),nt="";k.PdfHost=Ze,k.ZoomType=P,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`),require(`pdfjs-dist`)):typeof define==`function`&&define.amd?define([`exports`,`vue`,`pdfjs-dist`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.pdfjsVue3={},e.Vue,e.pdfjsLib))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=function(e){return e[e.Auto=0]=`Auto`,e[e.WidthFit=1]=`WidthFit`,e[e.PageFit=2]=`PageFit`,e[e.Custom=3]=`Custom`,e}({}),i=(0,t.defineComponent)({__name:`PdfPageText`,props:{viewport:{},page:{}},setup(e){let r=e,i=(0,t.ref)(),a;(0,t.watch)(()=>[r.viewport,r.page],()=>{o()});async function o(){let e=i.value,t=r.viewport;if(!(!e||!t)){for(a&&=(a.cancel(),void 0);e.firstChild;)e.removeChild(e.firstChild);a=new n.TextLayer({textContentSource:r.page.streamTextContent(),container:e,viewport:t}),await a.render()}}return(0,t.onMounted)(()=>{o()}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`rootEl`,ref:i,class:`pdf-text-layer`},null,512))}}),a={class:`pdf-page-layout`},o={class:`pdf-page-overlay`},s={key:0,class:`pdf-page-number`},c=1100,l=96/72,u=(0,t.defineComponent)({__name:`PdfPage`,props:{zoom:{},zoomType:{},hideText:{type:Boolean},hideNumber:{type:Boolean},viewport:{},page:{},observer:{}},emits:[`update:zoom`],setup(e,{expose:n,emit:u}){let d=e,f=u,p=(0,t.ref)(),m=(0,t.ref)(),h=(0,t.ref)(!1);n({rootEl:m,inViewport:h});let g=(0,t.computed)(()=>{let{width:e,height:t}=d.page.getViewport({scale:l}),{width:n,height:i}=d.viewport,a=0,o=1;switch(d.zoomType){case r.Auto:return a=Math.min(n,c)-40,o=a/e,l*o;case r.WidthFit:return a=n-40,o=a/e,l*o;case r.PageFit:return n>i?(o=i/t,l*o):(a=n-40,o=a/e,l*o)}return l*d.zoom}),_=(0,t.computed)(()=>g.value*(window?.devicePixelRatio||1)),v=(0,t.computed)(()=>d.page.getViewport({scale:g.value})),y=(0,t.computed)(()=>d.page.getViewport({scale:_.value}));(0,t.watch)(g,e=>{let t=e/l;Math.abs(t-d.zoom)>.05&&f(`update:zoom`,t)},{immediate:!0});let b;function x(){if(!d.page||!p.value)return;let e=d.page,t=v.value,n=y.value,r=p.value;r.width=Math.ceil(n.width),r.height=Math.ceil(n.height),r.style.width=Math.floor(t.width)+`px`,r.style.height=Math.floor(t.height)+`px`;let i=m.value;i&&(i.style.width=r.style.width,i.style.height=r.style.height);let a=r.getContext(`2d`);if(!(!a||!h.value)){if(b){b.cancel();return}b=e.render({canvas:r,canvasContext:a,viewport:y.value}),b.promise.then(()=>b=void 0).catch(()=>{b=void 0,x()})}}return(0,t.watch)(()=>[d.page,_.value,h.value],()=>{x()},{immediate:!0}),(0,t.onMounted)(()=>{x(),m.value&&d.observer?.observe(m.value)}),(0,t.onBeforeUnmount)(()=>{m.value&&d.observer?.unobserve(m.value)}),(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`rootEl`,ref:m,class:`pdf-page`},[(0,t.createElementVNode)(`div`,a,[(0,t.createElementVNode)(`canvas`,{ref_key:`canvas`,ref:p},null,512),(0,t.createElementVNode)(`div`,o,[e.hideText?(0,t.createCommentVNode)(``,!0):((0,t.openBlock)(),(0,t.createBlock)(i,{key:0,viewport:y.value,page:e.page},null,8,[`viewport`,`page`])),(0,t.renderSlot)(n.$slots,`default`,{displaySize:y.value})])]),e.hideNumber?(0,t.createCommentVNode)(``,!0):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,s,(0,t.toDisplayString)(e.page.pageNumber),1))],512))}}),d={key:0,class:`pdf-progress`},f=(0,t.defineComponent)({__name:`PdfDocument`,props:{hideText:{type:Boolean},hideNumber:{type:Boolean},zoomType:{},zoom:{},viewport:{},src:{}},emits:[`error`,`update:zoom`],setup(e,{emit:r}){let i=e,a=r,o=(0,t.shallowRef)(),s=(0,t.shallowRef)([]),c=(0,t.shallowRef)(),l=(0,t.ref)(),f=[],p=(0,t.ref)(!1),m=(0,t.ref)(0);function h(e){e&&(f.push(e),f.length==1&&(e.inViewport=!0))}function g(){s.value.forEach(e=>e.cleanup()),s.value=[];let e=o.value;e&&(e.destroy(),o.value=void 0),f=[]}return(0,t.watch)(()=>i.src,e=>{if(g(),!e)return;let t=(0,n.getDocument)(e);p.value=!0,t.onProgress=e=>{e.total&&(m.value=e.loaded/e.total)},t.promise.then(e=>{o.value=e;let t=[];for(let n=1;n<=e.numPages;n++)t.push(e.getPage(n));Promise.all(t).then(t=>{e===o.value&&(s.value=t)})}).catch(e=>{a(`error`,e)}).finally(()=>{p.value=!1})},{immediate:!0}),(0,t.onMounted)(()=>{c.value=new IntersectionObserver(e=>{e.forEach(e=>{let t=f.find(t=>t?.rootEl===e.target);t&&(t.inViewport=e.isIntersecting)})},{rootMargin:`0px`})}),(0,t.onBeforeUnmount)(()=>{g(),c.value?.disconnect()}),(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`rootEl`,ref:l},[(0,t.renderSlot)(n.$slots,`loading`,{src:i.src,loading:p.value,progress:m.value},()=>[p.value?((0,t.openBlock)(),(0,t.createElementBlock)(`p`,d,`loading `+(0,t.toDisplayString)(Math.ceil(100*m.value))+`%`,1)):(0,t.createCommentVNode)(``,!0)]),((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(s.value,i=>((0,t.openBlock)(),(0,t.createBlock)(u,{ref_for:!0,ref:h,key:i.pageNumber,page:i,"hide-number":e.hideNumber,"hide-text":e.hideText,"zoom-type":e.zoomType,zoom:e.zoom,"onUpdate:zoom":r[0]||=e=>a(`update:zoom`,e),observer:c.value,viewport:e.viewport},{default:(0,t.withCtx)(({displaySize:e})=>[(0,t.renderSlot)(n.$slots,`default`,{doc:o.value,page:i,displaySize:e})]),_:2},1032,[`page`,`hide-number`,`hide-text`,`zoom-type`,`zoom`,`observer`,`viewport`]))),128))],512))}});typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var p=()=>{};function m(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}function h(e,n={}){let r,i,a=p,o=e=>{clearTimeout(e),a(),a=p},s;return c=>{let l=(0,t.toValue)(e),u=(0,t.toValue)(n.maxWait);return r&&o(r),l<=0||u!==void 0&&u<=0?(i&&=(o(i),void 0),Promise.resolve(c())):new Promise((e,t)=>{a=n.rejectOnCancel?t:e,s=c,u&&!i&&(i=setTimeout(()=>{r&&o(r),i=void 0,e(s())},u)),r=setTimeout(()=>{i&&o(i),i=void 0,e(c())},l)})}}function g(e,t=200,n={}){return m(h(t,n),e)}e.PdfHost=(0,t.defineComponent)({__name:`PdfHost`,props:{workerSrc:{},sources:{},zoomType:{},zoom:{},hideText:{type:Boolean},hideNumber:{type:Boolean}},emits:[`update:zoom`,`update:zoomType`],setup(e,{expose:i,emit:a}){let o=e,s=a,c=(0,t.ref)();i({zoomIn:h,zoomOut:_}),(0,t.watch)(()=>o.workerSrc,e=>{e&&(n.GlobalWorkerOptions.workerSrc=e)},{immediate:!0});function l(e){e.ctrlKey&&(e.preventDefault(),e.deltaY<0?h():_())}function u(e){e.ctrlKey&&(e.key===`0`||e.which==48)&&s(`update:zoomType`,r.Auto)}let d=(0,t.ref)({width:0,height:0}),p=g(()=>{let e=c.value;e&&(d.value={width:e.offsetWidth,height:e.offsetHeight})},100);function m(e){let t=e%.25;return Number((e-t).toFixed(2))}function h(){let e=m((o.zoom||1)+.25);s(`update:zoom`,Math.min(e,2)),s(`update:zoomType`,r.Custom)}function _(){let e=m((o.zoom||1)-.25);s(`update:zoom`,Math.max(e,.25)),s(`update:zoomType`,r.Custom)}return(0,t.watch)(()=>o.zoom,(e,n)=>{let r=c.value;if(r&&e&&n){let i=r.scrollTop,a=r.scrollLeft,o=e/n;(0,t.nextTick)(()=>{r.scrollTop=i*o,r.scrollLeft=a*o})}}),(0,t.onMounted)(()=>{window.addEventListener(`resize`,p),p()}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,p)}),(n,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`rootEl`,ref:c,onWheel:l,onKeydown:u,tabindex:`0`,class:`pdf-host`},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.sources,a=>((0,t.openBlock)(),(0,t.createBlock)(f,{viewport:d.value,src:a,"hide-number":!!e.hideNumber,"hide-text":!!e.hideText,"zoom-type":e.zoomType||(0,t.unref)(r).Auto,zoom:e.zoom||1,"onUpdate:zoom":i[0]||=e=>s(`update:zoom`,e)},{loading:(0,t.withCtx)(({loading:e,progress:r})=>[(0,t.renderSlot)(n.$slots,`loading`,{source:a,loading:e,progress:r})]),default:(0,t.withCtx)(({doc:e,page:r,displaySize:i})=>[(0,t.renderSlot)(n.$slots,`page`,{source:a,doc:e,page:r,displaySize:i})]),_:2},1032,[`viewport`,`src`,`hide-number`,`hide-text`,`zoom-type`,`zoom`]))),256)),(0,t.renderSlot)(n.$slots,`default`)],544))}}),e.ZoomType=r});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdfjs-vue3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Using pdfjs to display PDFs as a vue 3 component.",
|
|
5
5
|
"author": "Eugene Wang",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"types": "./types/index.d.ts",
|
|
23
23
|
"main": "./dist/pdfjs-vue3.umd.js",
|
|
24
|
-
|
|
24
|
+
"style": "./dist/style.css",
|
|
25
25
|
"module": "./dist/pdfjs-vue3.es.js",
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
@@ -36,18 +36,19 @@
|
|
|
36
36
|
"preview": "vite preview"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"pdfjs-dist": "^
|
|
40
|
-
"vue": "^3.
|
|
39
|
+
"pdfjs-dist": "^5.6.205",
|
|
40
|
+
"vue": "^3.5.32"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/types": "^7.23.0",
|
|
44
|
-
"@types/
|
|
45
|
-
"@
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
"@types/node": "^25.5.2",
|
|
45
|
+
"@vitejs/plugin-vue": "^6.0.5",
|
|
46
|
+
"modern-normalize": "^3.0.1",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vite": "^8.0.3",
|
|
49
|
+
"vue-tsc": "^3.2.6"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@vueuse/core": "^14.2.1"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/types/PdfHost.vue.d.ts
CHANGED
|
@@ -1,30 +1,50 @@
|
|
|
1
1
|
import { PdfSource, ZoomType } from './types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/**
|
|
4
|
+
* Pdfjs's worker script url. Must be set if haven't been set elsewhere.
|
|
5
|
+
*/
|
|
6
|
+
workerSrc?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Array of pdf sources to display.
|
|
9
|
+
*/
|
|
10
|
+
sources: PdfSource[];
|
|
11
|
+
/**
|
|
12
|
+
* Type of zoom used. Defaults to Auto.
|
|
13
|
+
*/
|
|
14
|
+
zoomType?: ZoomType;
|
|
15
|
+
/**
|
|
16
|
+
* Display zoom percentage if using custom zoom, defaults to 1 (100%).
|
|
17
|
+
*/
|
|
18
|
+
zoom?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Hides the selectable text layer.
|
|
21
|
+
*/
|
|
22
|
+
hideText?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Hides page number display.
|
|
25
|
+
*/
|
|
26
|
+
hideNumber?: boolean;
|
|
27
|
+
};
|
|
2
28
|
declare function zoomIn(): void;
|
|
3
29
|
declare function zoomOut(): void;
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: import("vue").PropType<boolean>;
|
|
23
|
-
};
|
|
24
|
-
enablePinchZoom: {
|
|
25
|
-
type: import("vue").PropType<boolean>;
|
|
26
|
-
};
|
|
27
|
-
}, {
|
|
30
|
+
declare var __VLS_10: {
|
|
31
|
+
source: PdfSource;
|
|
32
|
+
loading: boolean;
|
|
33
|
+
progress: number;
|
|
34
|
+
}, __VLS_13: {
|
|
35
|
+
source: PdfSource;
|
|
36
|
+
doc: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;
|
|
37
|
+
page: import("pdfjs-dist/types/src/display/api").PDFPageProxy;
|
|
38
|
+
displaySize: import("pdfjs-dist/types/src/display/display_utils").PageViewport;
|
|
39
|
+
}, __VLS_15: {};
|
|
40
|
+
type __VLS_Slots = {} & {
|
|
41
|
+
loading?: (props: typeof __VLS_10) => any;
|
|
42
|
+
} & {
|
|
43
|
+
page?: (props: typeof __VLS_13) => any;
|
|
44
|
+
} & {
|
|
45
|
+
default?: (props: typeof __VLS_15) => any;
|
|
46
|
+
};
|
|
47
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
28
48
|
/**
|
|
29
49
|
* Try to increase zoom to the next level, up to 200%.
|
|
30
50
|
*/
|
|
@@ -33,51 +53,17 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
33
53
|
* Try to decrease zoom to the next level, down to 25%.
|
|
34
54
|
*/
|
|
35
55
|
zoomOut: typeof zoomOut;
|
|
36
|
-
},
|
|
37
|
-
"update:zoom": (zoom: number) =>
|
|
38
|
-
"update:zoomType": (zoomType: ZoomType) =>
|
|
39
|
-
}, string, import("vue").
|
|
40
|
-
workerSrc: {
|
|
41
|
-
type: import("vue").PropType<string>;
|
|
42
|
-
};
|
|
43
|
-
sources: {
|
|
44
|
-
type: import("vue").PropType<PdfSource[]>;
|
|
45
|
-
required: true;
|
|
46
|
-
};
|
|
47
|
-
zoomType: {
|
|
48
|
-
type: import("vue").PropType<ZoomType>;
|
|
49
|
-
};
|
|
50
|
-
zoom: {
|
|
51
|
-
type: import("vue").PropType<number>;
|
|
52
|
-
};
|
|
53
|
-
hideText: {
|
|
54
|
-
type: import("vue").PropType<boolean>;
|
|
55
|
-
};
|
|
56
|
-
hideNumber: {
|
|
57
|
-
type: import("vue").PropType<boolean>;
|
|
58
|
-
};
|
|
59
|
-
enablePinchZoom: {
|
|
60
|
-
type: import("vue").PropType<boolean>;
|
|
61
|
-
};
|
|
62
|
-
}>> & {
|
|
56
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
57
|
+
"update:zoom": (zoom: number) => any;
|
|
58
|
+
"update:zoomType": (zoomType: ZoomType) => any;
|
|
59
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
63
60
|
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
64
61
|
"onUpdate:zoomType"?: ((zoomType: ZoomType) => any) | undefined;
|
|
65
|
-
}, {}, {}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
loading: boolean;
|
|
69
|
-
progress: number;
|
|
70
|
-
}): any;
|
|
71
|
-
page?(_: {
|
|
72
|
-
source: PdfSource;
|
|
73
|
-
doc: import("pdfjs-dist/types/src/display/api").PDFDocumentProxy | undefined;
|
|
74
|
-
page: import("pdfjs-dist/types/src/display/api").PDFPageProxy;
|
|
75
|
-
displaySize: import("pdfjs-dist/types/src/display/display_utils").PageViewport;
|
|
76
|
-
}): any;
|
|
77
|
-
default?(_: {}): any;
|
|
78
|
-
}>;
|
|
62
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
63
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
64
|
+
declare const _default: typeof __VLS_export;
|
|
79
65
|
export default _default;
|
|
80
|
-
type
|
|
66
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
81
67
|
new (): {
|
|
82
68
|
$slots: S;
|
|
83
69
|
};
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PDFDataRangeTransport } from 'pdfjs-dist';
|
|
2
1
|
import type { TypedArray, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
|
|
3
2
|
/**
|
|
4
3
|
* Types of zooms supported in pdf display.
|
|
@@ -24,4 +23,4 @@ export declare enum ZoomType {
|
|
|
24
23
|
/**
|
|
25
24
|
* Source of pdf to display in the host.
|
|
26
25
|
*/
|
|
27
|
-
export type PdfSource = string | URL |
|
|
26
|
+
export type PdfSource = string | URL | TypedArray | ArrayBuffer | DocumentInitParameters;
|
package/dist/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.pdf-text-layer{position:absolute;text-align:initial;left:0;top:0;right:0;bottom:0;overflow:hidden;opacity:.2;line-height:1;text-size-adjust:none}.pdf-text-layer span,.pdf-text-layer br{color:transparent;position:absolute;white-space:pre;cursor:text;transform-origin:0% 0%}.pdf-text-layer span.markedContent{top:0;height:0}.pdf-text-layer .highlight{margin:-1px;padding:1px;background-color:#b400aa;border-radius:4px}.pdf-text-layer .highlight.appended{position:initial}.pdf-text-layer .highlight.begin{border-radius:4px 0 0 4px}.pdf-text-layer .highlight.end{border-radius:0 4px 4px 0}.pdf-text-layer .highlight.middle{border-radius:0}.pdf-text-layer .highlight.selected{background-color:#006400}.pdf-text-layer ::selection{background:rgb(0,153,255)}.pdf-text-layer br::selection{background:transparent}.pdf-text-layer .endOfContent{display:block;position:absolute;left:0;top:100%;right:0;bottom:0;z-index:-1;cursor:default;-webkit-user-select:none;user-select:none}.pdf-text-layer .endOfContent.active{top:0}.pdf-page{margin:1rem auto;display:flex;flex-direction:column}.pdf-page-layout{position:relative;display:flex;margin-bottom:.5rem;margin:auto;background:#fff;filter:drop-shadow(0 1px 2px rgb(0 0 0 / .1)) drop-shadow(0 1px 1px rgb(0 0 0 / .06))}.pdf-page-number{text-align:center;line-height:1.5}.pdf-page-overlay{position:absolute;top:0;left:0;right:0;bottom:0}.pdf-progress{text-align:center;padding:1rem}.pdf-host{height:100%;overflow:auto;padding:1rem 0;background:gainsboro;touch-action:pan-x pan-y}.pdf-host:focus{outline:none}
|