I have looked at jsPDF but the plugin strips CSS in the exported PDF. I have looked at html2canvas also, but that takes a screenshot of the current window. My HTML content is hidden from the user and I am looking for a solution that would create a PDF on the fly from a HTML block. Any suggestions?
EDIT: I just tried creating html2canvas to jsPDF but I get an empty pdf document. Can someone please tell me why? http://jsfiddle.net/5ud8jkvf/6320/
$('.download').on('click', function(){
html2canvas($('.print'), {
onrendered: function(canvas) {
$('#canvas').replaceWith(canvas);
},
//width: 200,
//height: 200
});
setTimeout(function(){
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
doc.fromHTML($('canvas').html(), 15, 15, {
'width': '200',
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
}, 500);
});