Is there some chance to generate PDF from HTML content. I mean something like print to PDF. I need to use very difficult html with technical draws (absolute positions, etc) and I need to take whole Vue file template and generate PDF.
2 Answers
This can be achieve with the jspdf library
http://raw.githack.com/MrRio/jsPDF/master/examples/html2pdf/showcase_supported_html.html
Example code:
<div id="html">My HTML</div>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js"></script>
<script>
var pdf = new jsPDF('p', 'pt', 'a4');
pdf.html(document.getElementById('html'), {
callback: function (pdf) {
pdf.save('a4.pdf');
}
});
</script>