var print = document.createElement('button');
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = 300;
canvas.height = 100;
ctx.fillStyle = '#000';
ctx.font = '15px sans-serif';
ctx.fillText('Fill Text, 18px, sans-serif', 10, 20);
print.innerHTML = 'Print';
document.body.appendChild(print);
document.body.appendChild(canvas);
print.addEventListener('click', function() {
window.print();
});
http://jsfiddle.net/vpetrychuk/LWup5/。打印画布内容
正如你所看到的画布中的文字显示ok,但点击“Print”按钮(并将页面保存为PDF)后,输出图像变得丑陋。
是否有机会打印画布内容而不模糊?