I want to generate a PDF with creating a dynamic HTML table and data using js. I am trying to use jsPDF but not applying CSS (inline or internal both are not working) pdf dynamic created table. I want the same layout as it is. would it be possible using any js (client-side)? do I need to create HTML or need to generate dynamically? I will show multiple records with the header column.
Thanks in advance!
function print() {
var table = $('<table class="mystyles"><thead><tr><th>Select</th><th>Name</th><th>Email</th></tr></thead></table>');
var name = "Test";
var email = "TestEmail";
var markup = "<tr><td><input type='checkbox' name='record'></td><td>" +
name +
"</td><td>" +
email +
"</td></tr>";
table.append(markup);
$('#contentId').append(table);
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
doc.fromHTML($('#contentId').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
headerFooterFormatting(doc, 2);
doc.save('sample-file.pdf');
};