1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
$(function () {
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
//Convert HTML to PDF using jsPDF
$('#cmd').click(function () {
var doc = new jsPDF();
doc.fromHTML(
$('#content').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
},
//Display a PDF in a new window
function () {
var string = doc.output('datauristring');
var iframe = "<iframe width='100%' height='100%' src='" + string + "'></iframe>"
var x = window.open();
x.document.open();
x.document.write(iframe);
x.document.close();
}
);
});
}); |
Partager