After a few hours of research, I found some of exporting the content of divs to pdf, including all styles. According to this page, vue-html2pdf does not work properly, so i used html2pdf. It takes a div with ref and converts it to pdf, downloading it at the same time:
<div ref="printable">Hello</div>
<button @click="export()">Export to PDF</button
export() {
html2pdf(this.$refs.document, {
margin: 1,
filename: 'document.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { dpi: 192, letterRendering: true },
jsPDF: { unit: 'in', format: 'letter', orientation: 'landscape' }
})
},
The problem is that it includes all the styles and i cannot export a hidden div. Is there any proper way to achieve this?