简体   繁体   English

将div和内容转换为图像

[英]Convert a div and contents inside it to image

I have a DIV container which has some text, background-image, image. 我有一个DIV容器,它有一些文本,背景图像,图像。 I need to convert that whole DIV contents into image and save. 我需要将整个DIV内容转换为图像并保存。

I have googled it around but could not find the perfect answer. 我用Google搜索了一下,却找不到完美的答案。 some are giving answers that uses a windows application , but i need it on a web platform . 有些人给出了使用Windows应用程序的答案,但我需要在网络平台上使用它。

any help will be highly appreciated 任何帮助将受到高度赞赏

From what I understood, you have to do that in the client side, so you should take a look at the toDataURL method of the canvas. 根据我的理解,你必须在客户端这样做,所以你应该看一下画布的toDataURL方法。

If you don't know, the canvas support text and image. 如果您不知道,画布支持文本和图像。

Example and little library at this link: http://www.nihilogic.dk/labs/canvas2image/ 此链接的示例和小型库: http//www.nihilogic.dk/labs/canvas2image/

http://html2canvas.hertzen.com/ http://html2canvas.hertzen.com/

Does't support IE though. 虽然不支持IE。 Looks solid other than that. 除此之外看起来很稳固。

这是可能的,修改代码http://html2canvas.hertzen.com/screenshots.html你可以执行所需的screenshot :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM