JSFiddle - React, Tailwind, and code Playground
by Rapha Souza
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.4.1/jspdf.debug.js"></script>
<div class="zima">
<h1> Header </h1>
<p class="text-center">This is the paragraph</p>
<p> content </p>
</div>
<button id="getPDF" onclick="getPDF()">Download PDF</button>
JavaScript
function getPDF() {
var doc = new jsPDF();
// We'll make our own renderer to skip this editor
var specialElementHandlers = {
'#getPDF': function(element, renderer){
return true;
},
'.controls': function(element, renderer){
return true;
}
};
// All units are in the set measurement for the document
// This can be changed to "pt" (points), "mm" (Default), "cm", "in"
doc.fromHTML($('.zima').get(0), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('Generated.pdf');
}