function print_voucher(){ // 打印的主要方法
var win=window.open();
win.document.write("");
win.print();
win.location.reload();
}
需要打开一个窗口进行打印,示例代码如下:
$(function(){
var canvas=document.getElementById("canvas");
var ctx=canvas.getContext("2d");
ctx.fillStyle="gold";
ctx.strokeStyle="blue";
ctx.lineWidth=5;
ctx.rect(50,50,100,100);
ctx.fill();
ctx.stroke();
function print_voucher(){
var win=window.open();
win.document.write("");
win.print();
win.location.reload();
}
$("#printVoucher").click(function(){ print_voucher(); });
}); // end $(function(){});
原文:http://www.cnblogs.com/LLSutdy/p/6751886.html
最后
以上就是飘逸店员最近收集整理的关于html5 直接打印,打印html5中Canvas的方法的全部内容,更多相关html5内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复