UNPKG

@progress/kendo-vue-pdf

Version:
9 lines (8 loc) 2.85 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";const m=require("vue");require("@progress/kendo-drawing");require("@progress/kendo-drawing/pdf");require("@progress/kendo-file-saver");const g=require("@progress/kendo-vue-common");function f(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const P=f(m),a=P,u=a.h,h=a.createApp,T="export.pdf",D="Kendo UI PDF Generator";class x{constructor(t,e,o,l,d={}){this.drawDOM=t,this.exportPDF=e,this.saveAs=o,this.domElement=l,this.options=d,this.convertPageTemplateToHtml=p=>{if(u&&h&&g.canUseDOM){const c=this,i=document.createElement("div");i.setAttribute("style","position:absolute; left: -5000px; top: 0px;");const r=document.createElement("div");i.appendChild(r),document.body.appendChild(i);let s;return s=h({render:function(){return u(c.options.pageTemplate,{pageNum:p.pageNum,totalPages:p.totalPages})},mounted:function(){this.$nextTick(function(){document.body.removeChild(i),s.unmount()})}}),s.mount(r),r.outerHTML}else{const c=a.extend?a:a.default,r=c.extend.call(c,this.options.pageTemplate),s=new r({propsData:{pageNum:p.pageNum,totalPages:p.totalPages}});return s.$mount(),s.$nextTick(function(){s.$destroy()}),s.$el.outerHTML}}}savePDF(t){const e=this.drawDOM(this.domElement,this.getDrawOptions()).then(o=>this.exportPDF(o,this.getPDFOptions())).then(o=>this.saveAs(o,this.options.fileName||T,this.getSaveOptions()));t&&e.then(t,t)}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||D,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}}}module.exports=x;