download shopping list PDF

This commit is contained in:
smilerz
2021-11-30 12:04:27 -06:00
parent 54ca8b2bd0
commit 2d7d160d1b
6 changed files with 14575 additions and 36 deletions

View File

@ -0,0 +1,32 @@
<template>
<div>
<a v-if="!button" class="dropdown-item" @click="downloadFile"><i :class="icon"></i> {{ label }}</a>
<b-button v-if="button" @click="downloadFile">{{ label }}</b-button>
</div>
</template>
<script>
import html2pdf from "html2pdf.js"
export default {
name: "DownloadPDF",
props: {
dom: { type: String },
name: { type: String },
icon: { type: String },
label: { type: String },
button: { type: Boolean, default: false },
},
methods: {
downloadFile() {
const doc = document.querySelector(this.dom)
var options = {
margin: 1,
filename: this.name,
}
html2pdf().from(doc).set(options).save()
},
},
}
</script>