pdfjs-vue3 0.1.9 → 0.1.10
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.es.js +485 -0
- package/dist/pdfjs-vue3.umd.js +1 -0
- package/dist/style.css +1 -0
- package/package.json +1 -1
- package/types/PdfHost.vue.d.ts +84 -0
- package/types/index.d.ts +3 -0
- package/types/types.d.ts +27 -0
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
import { defineComponent as N, ref as P, watch as j, onMounted as L, openBlock as T, createElementBlock as $, computed as M, onBeforeUnmount as G, createElementVNode as W, createBlock as R, createCommentVNode as F, renderSlot as E, toDisplayString as Z, shallowRef as B, Fragment as ee, renderList as te, withCtx as A, nextTick as ae, unref as V } from "vue";
|
|
2
|
+
import { renderTextLayer as se, getDocument as le, GlobalWorkerOptions as ue } from "pdfjs-dist";
|
|
3
|
+
var S = /* @__PURE__ */ ((e) => (e[e.Auto = 0] = "Auto", e[e.WidthFit = 1] = "WidthFit", e[e.PageFit = 2] = "PageFit", e[e.Custom = 3] = "Custom", e))(S || {});
|
|
4
|
+
const ce = /* @__PURE__ */ N({
|
|
5
|
+
__name: "PdfPageText",
|
|
6
|
+
props: {
|
|
7
|
+
viewport: {},
|
|
8
|
+
page: {}
|
|
9
|
+
},
|
|
10
|
+
setup(e) {
|
|
11
|
+
const a = e, u = P(), r = P();
|
|
12
|
+
j(() => a.page, async (v) => {
|
|
13
|
+
u.value = await v.getTextContent();
|
|
14
|
+
}, { immediate: !0 }), j(() => [u.value, r.value, a.viewport], () => {
|
|
15
|
+
m();
|
|
16
|
+
});
|
|
17
|
+
let c;
|
|
18
|
+
function m() {
|
|
19
|
+
const v = r.value, l = u.value, h = a.viewport;
|
|
20
|
+
if (!(!v || !l || !h)) {
|
|
21
|
+
if (c) {
|
|
22
|
+
c.cancel();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
for (; v.firstChild; )
|
|
26
|
+
v.removeChild(v.firstChild);
|
|
27
|
+
c = se({
|
|
28
|
+
textContentSource: l,
|
|
29
|
+
container: v,
|
|
30
|
+
viewport: h
|
|
31
|
+
// enhanceTextSelection: true
|
|
32
|
+
}), c.promise.then(() => {
|
|
33
|
+
c = void 0;
|
|
34
|
+
}).catch(() => {
|
|
35
|
+
c = void 0;
|
|
36
|
+
}).finally(() => {
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return L(() => {
|
|
41
|
+
m();
|
|
42
|
+
}), (v, l) => (T(), $("div", {
|
|
43
|
+
ref_key: "rootEl",
|
|
44
|
+
ref: r,
|
|
45
|
+
class: "pdf-text-layer"
|
|
46
|
+
}, null, 512));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const de = { class: "pdf-page-layout" }, fe = { class: "pdf-page-overlay" }, pe = {
|
|
50
|
+
key: 0,
|
|
51
|
+
class: "pdf-page-number"
|
|
52
|
+
}, ve = 1100, k = 96 / 72, me = /* @__PURE__ */ N({
|
|
53
|
+
__name: "PdfPage",
|
|
54
|
+
props: {
|
|
55
|
+
zoom: {},
|
|
56
|
+
zoomType: {},
|
|
57
|
+
hideText: { type: Boolean },
|
|
58
|
+
hideNumber: { type: Boolean },
|
|
59
|
+
viewport: {},
|
|
60
|
+
page: {},
|
|
61
|
+
observer: {}
|
|
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;
|
|
279
|
+
}
|
|
280
|
+
var nt = ot, rt = Ie, Y = oe, it = nt, q = 0 / 0, at = /^[-+]0x[0-9a-f]+$/i, st = /^0b[01]+$/i, lt = /^0o[0-7]+$/i, ut = parseInt;
|
|
281
|
+
function ct(e) {
|
|
282
|
+
if (typeof e == "number")
|
|
283
|
+
return e;
|
|
284
|
+
if (it(e))
|
|
285
|
+
return q;
|
|
286
|
+
if (Y(e)) {
|
|
287
|
+
var a = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
288
|
+
e = Y(a) ? a + "" : a;
|
|
289
|
+
}
|
|
290
|
+
if (typeof e != "string")
|
|
291
|
+
return e === 0 ? e : +e;
|
|
292
|
+
e = rt(e);
|
|
293
|
+
var u = st.test(e);
|
|
294
|
+
return u || lt.test(e) ? ut(e.slice(2), u ? 2 : 8) : at.test(e) ? q : +e;
|
|
295
|
+
}
|
|
296
|
+
var dt = ct, ft = oe, D = $e, J = dt, pt = "Expected a function", vt = Math.max, mt = Math.min;
|
|
297
|
+
function ht(e, a, u) {
|
|
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;
|
|
343
|
+
}
|
|
344
|
+
var gt = ht;
|
|
345
|
+
const Q = /* @__PURE__ */ be(gt), wt = /* @__PURE__ */ N({
|
|
346
|
+
__name: "PdfHost",
|
|
347
|
+
props: {
|
|
348
|
+
workerSrc: {},
|
|
349
|
+
sources: {},
|
|
350
|
+
zoomType: {},
|
|
351
|
+
zoom: {},
|
|
352
|
+
hideText: { type: Boolean },
|
|
353
|
+
hideNumber: { type: Boolean },
|
|
354
|
+
enablePinchZoom: { type: Boolean }
|
|
355
|
+
},
|
|
356
|
+
emits: ["update:zoom", "update:zoomType"],
|
|
357
|
+
setup(e, { expose: a, emit: u }) {
|
|
358
|
+
const r = e, c = P();
|
|
359
|
+
a({
|
|
360
|
+
/**
|
|
361
|
+
* Try to increase zoom to the next level, up to 200%.
|
|
362
|
+
*/
|
|
363
|
+
zoomIn: w,
|
|
364
|
+
/**
|
|
365
|
+
* Try to decrease zoom to the next level, down to 25%.
|
|
366
|
+
*/
|
|
367
|
+
zoomOut: g
|
|
368
|
+
}), j(() => r.workerSrc, (t) => {
|
|
369
|
+
t && (ue.workerSrc = t);
|
|
370
|
+
}, { immediate: !0 });
|
|
371
|
+
function m(t) {
|
|
372
|
+
t.ctrlKey && (t.preventDefault(), t.deltaY < 0 ? w() : g());
|
|
373
|
+
}
|
|
374
|
+
function v(t) {
|
|
375
|
+
t.ctrlKey && (t.key === "0" || t.which == 48) && u("update:zoomType", S.Auto);
|
|
376
|
+
}
|
|
377
|
+
const l = P({ width: 0, height: 0 }), h = Q(() => {
|
|
378
|
+
const t = c.value;
|
|
379
|
+
t && (l.value = {
|
|
380
|
+
width: t.offsetWidth,
|
|
381
|
+
height: t.offsetHeight
|
|
382
|
+
});
|
|
383
|
+
}, 100);
|
|
384
|
+
function y(t) {
|
|
385
|
+
const i = t % 0.25;
|
|
386
|
+
return Number((t - i).toFixed(2));
|
|
387
|
+
}
|
|
388
|
+
function w() {
|
|
389
|
+
const t = y((r.zoom || 1) + 0.25);
|
|
390
|
+
u("update:zoom", Math.min(t, 2)), u("update:zoomType", S.Custom);
|
|
391
|
+
}
|
|
392
|
+
function g() {
|
|
393
|
+
const t = y((r.zoom || 1) - 0.25);
|
|
394
|
+
u("update:zoom", Math.max(t, 0.25)), u("update:zoomType", S.Custom);
|
|
395
|
+
}
|
|
396
|
+
j(() => r.zoom, (t, i) => {
|
|
397
|
+
const b = c.value;
|
|
398
|
+
if (b && t && i) {
|
|
399
|
+
const _ = b.scrollTop, z = b.scrollLeft, p = t / i;
|
|
400
|
+
ae(() => {
|
|
401
|
+
b.scrollTop = _ * p, b.scrollLeft = z * p;
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}), L(() => {
|
|
405
|
+
window.addEventListener("resize", h), h();
|
|
406
|
+
}), G(() => {
|
|
407
|
+
window.removeEventListener("resize", h);
|
|
408
|
+
});
|
|
409
|
+
const o = [];
|
|
410
|
+
let n = -1;
|
|
411
|
+
function s(t) {
|
|
412
|
+
r.enablePinchZoom && o.push(t);
|
|
413
|
+
}
|
|
414
|
+
const d = Q((t) => {
|
|
415
|
+
if (r.enablePinchZoom) {
|
|
416
|
+
for (let i = 0; i < o.length; i++)
|
|
417
|
+
if (t.pointerId === o[i].pointerId) {
|
|
418
|
+
o[i] = t;
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
if (o.length === 2) {
|
|
422
|
+
const i = Math.abs(o[0].clientX - o[1].clientX), b = Math.abs(o[0].clientY - o[1].clientY), _ = Math.sqrt(Math.pow(i, 2) + Math.pow(b, 2));
|
|
423
|
+
n > 0 && (_ > n && w(), _ < n && g()), n = _;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}, 10);
|
|
427
|
+
function f(t) {
|
|
428
|
+
if (r.enablePinchZoom) {
|
|
429
|
+
for (let i = 0; i < o.length; i++)
|
|
430
|
+
if (o[i].pointerId === t.pointerId) {
|
|
431
|
+
o.splice(i, 1);
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
o.length < 2 && (n = -1);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return (t, i) => (T(), $("div", {
|
|
438
|
+
ref_key: "rootEl",
|
|
439
|
+
ref: c,
|
|
440
|
+
onWheel: m,
|
|
441
|
+
onKeydown: v,
|
|
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
|
+
}
|
|
481
|
+
});
|
|
482
|
+
export {
|
|
483
|
+
wt as PdfHost,
|
|
484
|
+
S as ZoomType
|
|
485
|
+
};
|
|
@@ -0,0 +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"})});
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
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}
|
package/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PdfSource, ZoomType } from './types';
|
|
2
|
+
declare function zoomIn(): void;
|
|
3
|
+
declare function zoomOut(): void;
|
|
4
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
5
|
+
workerSrc: {
|
|
6
|
+
type: import("vue").PropType<string>;
|
|
7
|
+
};
|
|
8
|
+
sources: {
|
|
9
|
+
type: import("vue").PropType<PdfSource[]>;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
zoomType: {
|
|
13
|
+
type: import("vue").PropType<ZoomType>;
|
|
14
|
+
};
|
|
15
|
+
zoom: {
|
|
16
|
+
type: import("vue").PropType<number>;
|
|
17
|
+
};
|
|
18
|
+
hideText: {
|
|
19
|
+
type: import("vue").PropType<boolean>;
|
|
20
|
+
};
|
|
21
|
+
hideNumber: {
|
|
22
|
+
type: import("vue").PropType<boolean>;
|
|
23
|
+
};
|
|
24
|
+
enablePinchZoom: {
|
|
25
|
+
type: import("vue").PropType<boolean>;
|
|
26
|
+
};
|
|
27
|
+
}, {
|
|
28
|
+
/**
|
|
29
|
+
* Try to increase zoom to the next level, up to 200%.
|
|
30
|
+
*/
|
|
31
|
+
zoomIn: typeof zoomIn;
|
|
32
|
+
/**
|
|
33
|
+
* Try to decrease zoom to the next level, down to 25%.
|
|
34
|
+
*/
|
|
35
|
+
zoomOut: typeof zoomOut;
|
|
36
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
37
|
+
"update:zoom": (zoom: number) => void;
|
|
38
|
+
"update:zoomType": (zoomType: ZoomType) => void;
|
|
39
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
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
|
+
}>> & {
|
|
63
|
+
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
64
|
+
"onUpdate:zoomType"?: ((zoomType: ZoomType) => any) | undefined;
|
|
65
|
+
}, {}, {}>, {
|
|
66
|
+
loading?(_: {
|
|
67
|
+
source: PdfSource;
|
|
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
|
+
}>;
|
|
79
|
+
export default _default;
|
|
80
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
81
|
+
new (): {
|
|
82
|
+
$slots: S;
|
|
83
|
+
};
|
|
84
|
+
};
|
package/types/index.d.ts
ADDED
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PDFDataRangeTransport } from 'pdfjs-dist';
|
|
2
|
+
import type { TypedArray, DocumentInitParameters } from 'pdfjs-dist/types/src/display/api';
|
|
3
|
+
/**
|
|
4
|
+
* Types of zooms supported in pdf display.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum ZoomType {
|
|
7
|
+
/**
|
|
8
|
+
* Auto zoom to fit width of host until a certain limit.
|
|
9
|
+
*/
|
|
10
|
+
Auto = 0,
|
|
11
|
+
/**
|
|
12
|
+
* Fits width of host with no limit.
|
|
13
|
+
*/
|
|
14
|
+
WidthFit = 1,
|
|
15
|
+
/**
|
|
16
|
+
* Fits whole page in the host.
|
|
17
|
+
*/
|
|
18
|
+
PageFit = 2,
|
|
19
|
+
/**
|
|
20
|
+
* Custom zoom value percentage.
|
|
21
|
+
*/
|
|
22
|
+
Custom = 3
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Source of pdf to display in the host.
|
|
26
|
+
*/
|
|
27
|
+
export type PdfSource = string | URL | PDFDataRangeTransport | TypedArray | DocumentInitParameters;
|