如何将DOM树转换为图像 [英] How can I convert a DOM Tree into an Image

查看:379
本文介绍了如何将DOM树转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页,我有一个div,其中有一个复杂的DOM树。它在大多数浏览器(IE 6-8,FF 2.x-3.5.x,Chrome,Safari)中显示良好,但是当我尝试打印页面时,我遇到了一些跨浏览器问题,有些工作在一些时间而其他人根本不工作。



我的想法是,如果我可以将DOM节点发送到服务器,请将DOM树解析成图像并使用该图像在浏览器中进行打印,我会一一解决这个问题。



有没有人知道一个简单的方法来做到这一点?



我有apache运行mod_python和PHP和IIS 6运行.NET 2.0,所以我可以实现它在任何一个,真的没有我的偏好:)



任何想法?

解决方案

我用这个C#代码以前获取网页截图的基础,并且工作得很好。



网页缩略图


I'm have a web page where I have a div within which there is a somewhat complex DOM tree. It displays fine across most browsers(IE 6-8, FF 2.x-3.5.x, Chrome, Safari) but when I try to print the page I'm having some cross-browser problems, some work half some of the time and others don't work at all.

I had the idea that if I could send offending the DOM nodes to the server, parse the DOM tree out into an image there and use that image to print in the browser, I'd solve this problem in one fell swoop.

Does anybody know of an easy way to do this?

I've got apache running mod_python and PHP and IIS 6 running .NET 2.0 so I could implement it on either one of those, really no preference on my part :)

Any ideas?

解决方案

I have used this C# code as a basis for getting screenshots of web pages before, and it worked really well.

Web Page Thumbnailer

这篇关于如何将DOM树转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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