打印canvas标签的内容 [英] Printing the contents of the canvas tag

查看:195
本文介绍了打印canvas标签的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个应用程序画布。我在画布中加载了更多图像(png,gif)。当我在浏览器(opera)上单击打印时,不会打印canvas标签的内容。使用其他浏览器(FF,IE,Chrome),没有问题。为什么?

I make an application canvas. I load more image (png, gif) in canvas. When I click print on my browser (opera), the contents of the canvas tag does not print. With other browsers (FF, IE, Chrome), there is no problem. Why?

推荐答案

将HTML Canvas捕获为gif / jpg / png / pdf?可能会有用。

var canvas = document.getElementById("mycanvas");
var img    = canvas.toDataURL("image/png");

使用IMG中的值,您可以将其写为新图像,如下所示:

with the value in IMG you can write it out as a new Image like so:

document.write('<img src="'+img+'"/>');

这篇关于打印canvas标签的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆