Export to PDF using vue3 and html2pdf.js
npm install vue3-simple-html2pdf- Export and auto download PDF using vue3 and html2pdf.js.
- Easy to custom any PDF style because it will be export from real html.
- Can use custom css style for pdf page using vue style.
```
npm install --save vue3-simple-html2pdf
or yarn
``
yarn add vue3-simple-html2pdf
import Vue3SimpleHtml2pdf from "vue3-simple-html2pdf";
Vue.use(Vue3SimpleHtml2pdf);
`Use component
`
ref="vue3SimpleHtml2pdf"
:options="pdfOptions"
:filename="exportFilename"
>
HTML Table
Company
Contact
Country
Alfreds Futterkiste
Maria Anders
Germany
Centro comercial Moctezuma
Francisco Chang
Mexico
Ernst Handel
Roland Mendel
Austria
Island Trading
Helen Bennett
UK
Laughing Bacchus Winecellars
Yoshi Tannamuri
Canada
Magazzini Alimentari Riuniti
Giovanni Rovelli
Italy

1
...
// Props
pdfOptions = {
margin: 15,
image: {
type: 'jpeg',
quality: 1,
},
html2canvas: { scale: 3 },
jsPDF: {
unit: 'mm',
format: 'a4',
orientation: 'p',
},
},
exportFilename: 'my-custom-file.pdf',
...
`Call start download pdf
`
this.$refs.vue3SimpleHtml2pdf.download()
`
To break page, use
html2pdf__page-break`
`To add page number, use
html2pdf__page-number`
{{ pageNumber }}
``The MIT License