├── type.d.ts ├── index.js ├── tsconfig.json ├── src ├── index.js └── vue3-html2pdf.vue ├── package.json ├── dist ├── sango-html2pdf.min.js ├── _sango_ssr.js └── _sango_esm.js ├── README.md └── yarn.lock /type.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'vue3-html2pdf' { 2 | import Vue3Html2pdf from 'vue3-html2pdf' 3 | export { Vue3Html2pdf } 4 | } 5 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import component from 'sango-html2pdf.vue'; 2 | const install = function (app) { 3 | app.component('SangoHtml2pdf', component); 4 | } 5 | 6 | export default { 7 | install 8 | } 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "declaration": true, 5 | "emitDeclarationOnly": true, 6 | //"outDir": "types" 7 | }, 8 | // "include": [ 9 | // "src/index.js" 10 | // ], 11 | } 12 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | // Import vue component 2 | import component from './vue3-html2pdf.vue'; 3 | 4 | // install function executed by Vue.use() 5 | function install(Vue) { 6 | if (install.installed) return; 7 | install.installed = true; 8 | Vue.component('Vue3Html2pdf', component); 9 | } 10 | 11 | // Create module definition for Vue.use() 12 | const plugin = { 13 | install, 14 | }; 15 | 16 | // Inject install function into component - allows component 17 | // to be registered with Vue.component() 18 | component.install = install; 19 | 20 | // Export component by default 21 | export default component; 22 | 23 | // It's possible to expose named exports when writing components that can 24 | // also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo'; 25 | // export const RollupDemoDirective = component; 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue3-html2pdf", 3 | "version": "1.1.2", 4 | "description": "A vue3 wrapper that use html2pdf for convert html to pdf", 5 | "main": "src/index.js", 6 | "types": "type.d.ts", 7 | "files": [ 8 | "src/*", 9 | "type.d.ts" 10 | ], 11 | "scripts": { 12 | "build": "cross-env NODE_ENV=production rollup --config build/rollup.config.js", 13 | "build:ssr": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format cjs", 14 | "build:es": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format es", 15 | "build:unpkg": "cross-env NODE_ENV=production rollup --config build/rollup.config.js --format iife" 16 | }, 17 | "keywords": [ 18 | "pdf-generation", 19 | "vuejs", 20 | "client-side", 21 | "html", 22 | "canvas", 23 | "html2pdf" 24 | ], 25 | "dependencies": { 26 | "@vue/compiler-sfc": "^3.0.11", 27 | "html2pdf.js": "^0.9.2" 28 | }, 29 | "devDependencies": { 30 | "@rollup/plugin-alias": "^3.1.2", 31 | "@rollup/plugin-buble": "^0.21.3", 32 | "@rollup/plugin-replace": "^2.4.2", 33 | "cross-env": "^7.0.3", 34 | "minimist": "^1.2.5", 35 | "rollup": "^2.45.2", 36 | "rollup-plugin-commonjs": "^10.1.0", 37 | "rollup-plugin-terser": "^7.0.2", 38 | "rollup-plugin-vue": "6.0.0", 39 | "typescript": "^4.1.2", 40 | "vue": "^3.0.0", 41 | "vue-template-compiler": "^2.6.12" 42 | }, 43 | "engines": { 44 | "node": ">=8" 45 | }, 46 | "repository": { 47 | "type": "git", 48 | "url": "git+https://github.com/raiblaze/vue3-html2pdf.git" 49 | }, 50 | "author": "Rai Blaze", 51 | "license": "MIT", 52 | "bugs": { 53 | "url": "https://github.com/raiblaze/vue3-html2pdf/issues" 54 | }, 55 | "homepage": "https://github.com/raiblaze/vue3-html2pdf#readme" 56 | } 57 | -------------------------------------------------------------------------------- /dist/sango-html2pdf.min.js: -------------------------------------------------------------------------------- 1 | var SangoHtml2pdf=function(e,t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var a={props:{showLayout:{type:Boolean,default:!1},floatLayout:{type:Boolean,default:!0},enableDownload:{type:Boolean,default:!0},previewModal:{type:Boolean,default:!1},paginateElementsByHeight:{type:Number},filename:{type:String,default:""+(new Date).getTime()},pdfQuality:{type:Number,default:2},pdfFormat:{default:"a4"},pdfOrientation:{type:String,default:"portrait"},pdfContentWidth:{default:"800px"},htmlToPdfOptions:{type:Object},manualPagination:{type:Boolean,default:!1}},data:function(){return{hasAlreadyParsed:!1,progress:0,pdfWindow:null,pdfFile:null}},watch:{progress:function(e){this.$emit("progress",e)},paginateElementsByHeight:function(){this.resetPagination()},$props:{handler:function(){this.validateProps()},deep:!0,immediate:!0}},methods:{validateProps:function(){this.manualPagination||void 0===this.paginateElementsByHeight&&console.error("Error: paginate-elements-by-height is required if manual-pagination is false")},resetPagination:function(){var e=this.$refs.pdfContent.getElementsByClassName("html2pdf__page-break"),t=e.length-1;if(-1!==t){this.hasAlreadyParsed=!1;for(var a=t;a>=0;a--)e[a].parentNode.removeChild(e[a])}},generatePdf:function(){this.$emit("startPagination"),this.progress=0,this.paginationOfElements()},paginationOfElements:function(){if(this.progress=25,this.manualPagination)return this.progress=70,this.$emit("hasPaginated"),void this.downloadPdf();if(this.hasAlreadyParsed)this.progress=70;else{var e=this.$refs.pdfContent,t=Array.from(this.$refs.pdfContent.children),a=0;for(var n of t){if("html2pdf__page-break"===n.classList[0])a=0;else{var i=n.clientHeight,o=n.currentStyle||window.getComputedStyle(n),s=i+(parseInt(o.marginTop)+parseInt(o.marginBottom));if(a+i 2 |
3 |
10 |
15 | 16 |
17 |
18 | 19 | 20 |
21 | 22 | 23 |