将HTML画布复制为剪贴板作为图像 [英] Copy HTML canvas to clipboard as image

查看:1606
本文介绍了将HTML画布复制为剪贴板作为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,我正在为一个客户端管理,该客户端使用一个使用画布生成图形的图形库。客户希望用户能够复制站点中的任何图形,以便将其粘贴到word文档中。具体问题:

I have a web application I'm administering for a client which uses a graphing library which generates graphs using a canvas. The client wants the user to be able to copy any graph in the site so that it can be pasted into a word document. The specific question:

是否可以将HTML画布元素作为图像复制到剪贴板?

Is it possible to copy an HTML canvas element to the clipboard as an image?

我知道可以将画布保存为图像,但它比复制/粘贴更麻烦。

I know that it is possible to save a canvas as an image, but it's somewhat more cumbersome than copy/paste.

编辑:
我了解到你可以将画布转换为带有数据URI src的图像,但该图像上的复制和粘贴支持是混合的。 Firefox允许您从浏览器中复制并粘贴这些图像,但Chrome不会。

I've learned that you can convert the canvas over to an image with a data URI src, but the copy and paste support on that image is mixed. Firefox allows you to copy and paste these images out of a browser, but chrome doesn't.

截至目前,似乎没有可靠的方法复制并粘贴一个canvas元素。

As of right now, it appears that there is not a reliable way to copy and paste a canvas element.

推荐答案

你不能直接用Javascript与剪贴板交互,但是可以借助Flash帮助它。

You cannot interact with clipboard directly with Javascript, but it could be possible with help of Flash.

您可以尝试 http://这里建议的code.google.com/p/zeroclipboard/ 如何使用JavaScript复制到剪贴板?

复制二进制数据可能会产生问题。

Copying binary data could be problematic thou.

参见

http://danielmclaren.com/node/91

这篇关于将HTML画布复制为剪贴板作为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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