UNPKG

@progress/kendo-vue-pdf

Version:
97 lines (96 loc) 3.36 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as l from "vue"; import "@progress/kendo-drawing"; import "@progress/kendo-drawing/pdf"; import "@progress/kendo-file-saver"; import { canUseDOM as u } from "@progress/kendo-vue-common"; const n = l, h = n.h, m = n.createApp, g = "export.pdf", P = "Kendo UI PDF Generator"; class k { constructor(e, r, o, c, d = {}) { this.drawDOM = e, this.exportPDF = r, this.saveAs = o, this.domElement = c, this.options = d, this.convertPageTemplateToHtml = (p) => { if (h && m && u) { const a = this, s = document.createElement("div"); s.setAttribute("style", "position:absolute; left: -5000px; top: 0px;"); const i = document.createElement("div"); s.appendChild(i), document.body.appendChild(s); let t; return t = m({ render: function() { return h( a.options.pageTemplate, { pageNum: p.pageNum, totalPages: p.totalPages } ); }, mounted: function() { this.$nextTick(function() { document.body.removeChild(s), t.unmount(); }); } }), t.mount(i), i.outerHTML; } else { const a = n.extend ? n : n.default, i = a.extend.call(a, this.options.pageTemplate), t = new i({ propsData: { pageNum: p.pageNum, totalPages: p.totalPages } }); return t.$mount(), t.$nextTick(function() { t.$destroy(); }), t.$el.outerHTML; } }; } savePDF(e) { const r = this.drawDOM(this.domElement, this.getDrawOptions()).then((o) => this.exportPDF(o, this.getPDFOptions())).then((o) => this.saveAs(o, this.options.fileName || g, this.getSaveOptions())); e && r.then(e, e); } getDrawOptions() { return { avoidLinks: this.options.avoidLinks, forcePageBreak: this.options.forcePageBreak, keepTogether: this.options.keepTogether, margin: this.options.margin, paperSize: this.options.paperSize, landscape: this.options.landscape, repeatHeaders: this.options.repeatHeaders, scale: this.options.scale, template: this.options.pageTemplate && this.convertPageTemplateToHtml }; } getPDFOptions() { return { author: this.options.author, creator: this.options.creator || P, date: this.options.date, imgDPI: this.options.imageResolution, keywords: this.options.keywords, landscape: this.options.landscape, margin: this.options.margin, multiPage: !0, paperSize: this.options.paperSize, producer: this.options.producer, subject: this.options.subject, title: this.options.title }; } getSaveOptions() { return { forceProxy: this.options.forceProxy, proxyData: this.options.proxyData, proxyTarget: this.options.proxyTarget, proxyURL: this.options.proxyURL }; } } export { k as default };