UNPKG

@ceereals/vue-pdf

Version:

Vue PDF - Create PDF documents using Vue components

103 lines (102 loc) 3.05 kB
import { defineComponent as f, useSlots as m, computed as v, createElementBlock as w, openBlock as p, createCommentVNode as D, unref as c, renderSlot as P, createTextVNode as S, toDisplayString as T } from "vue"; import { u as b } from "../index-BUmnDTSs.js"; import { C as G, g as I, j as R, c as q, D as j, E as z, G as A, I as H, b as J, k as K, L as M, N as O, P as Q, a as W, h as X, i as Y, l as Z, R as U, S as ee, e as oe, f as re, T as ae, d as te, V as ne, o as se } from "../index-BUmnDTSs.js"; const g = Symbol.for("root"), _ = ["src"], L = /* @__PURE__ */ f({ __name: "PDFViewer", props: { showToolbar: { type: Boolean, default: !0 }, enableProvideBridge: { type: Boolean, default: !0 } }, setup(l, { expose: i }) { const r = l, d = m(), { url: o, execute: n, root: a } = b( () => d.default().filter((s) => s.type !== Symbol.for("v-cmt"))[0], { enableProvideBridge: r.enableProvideBridge } ); i({ execute: n, // @ts-ignore [g]: a }); const t = v( () => o.value ? `${o == null ? void 0 : o.value}${r.showToolbar ? `#toolbar=${+r.showToolbar}` : ""}` : "" ); return (s, u) => (p(), w("iframe", { src: t.value, frameborder: "0" }, null, 8, _)); } }), k = ["href", "download"], F = /* @__PURE__ */ f({ __name: "PDFDownloadLink", props: { fileName: { default: "document.pdf" }, label: { default: "Download" } }, emits: ["click"], setup(l, { expose: i, emit: r }) { const d = l, o = r, n = m(); if (!n.default) throw new Error("PDFDownloadLink requires a default slot"); const { url: a, blob: t, isLoading: s } = b( () => n.default().filter((e) => e.type !== Symbol.for("v-cmt"))[0] ?? (() => { throw new Error("PDFDownloadLink requires a default slot"); })() ), u = () => { window.navigator.msSaveBlob && window.navigator.msSaveBlob(t.value, d.fileName); }, h = (e) => { u(), o("click", e); }; return i({ blob: t, isLoading: s, url: a }), (e, y) => c(a) ? (p(), w("a", { key: 0, href: c(a), download: e.fileName, onClick: h }, [ P(e.$slots, "label", { blob: c(t) }, () => [ S(T(e.label), 1) ]) ], 8, k)) : D("", !0); } }), x = () => { throw new Error("renderToFile is not available in the browser"); }, C = () => { throw new Error("renderToBuffer is not available in the browser"); }, N = () => { throw new Error("renderToStream is not available in the browser"); }; export { G as Canvas, I as Circle, R as ClipPath, q as Defs, j as Document, z as Ellipse, A as G, H as Image, J as Line, K as LinearGradient, M as Link, O as Note, F as PDFDownloadLink, L as PDFViewer, Q as Page, W as Path, X as Polygon, Y as Polyline, Z as RadialGradient, U as Rect, ee as Stop, oe as Svg, re as SvgText, ae as Text, te as Tspan, ne as View, se as fontStore, C as renderToBuffer, x as renderToFile, N as renderToStream, b as usePdf };