将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