Программирование
1
Вклад в тег
rasterizeHTML.drawHTML($('#wrap')[0].outerHTML,canvas).then(function success(renderResult) {
canvas = document.getElementById("canvas_c");
var data=canvas.toDataURL();
// resize the canvas
canvas.width = width;
canvas.height = height;
// scale and redraw the canvas content
var img=new Image();
img.onload=function() {
var ctx=canvas.getContext("2d");
ctx.drawImage(img,0,0,img.width,img.height,0,0,canvas.width,canvas.height);
var imgData = canvas.toDataURL("image/png", 1.0);
var doc = new jsPDF();
doc.addImage(imgData, 'PNG', 5, 5, width/15, height/15);
doc.save('filename.pdf');
};
img.src=data;
});