如何使用java将HTML代码转换为Image? [英] How can I convert HTML code to Image using java?

查看:1517
本文介绍了如何使用java将HTML代码转换为Image?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个程序,将我最喜欢的网站显示为桌面背景,但我在将HTML代码转换为图像时遇到问题。在code.google.com上有一个名为htmltoimage的API,但它无法正常工作我搜索过很多资源,但是没有免费的API可以帮我解决这个问题。如果你知道任何可以帮我解决这个问题的API或想法,请告诉我。



谢谢。

解决方案

您面临将HTML代码转换为图像的问题,因为原则上没有这种转换。



每个固定的HTML都不会生成任何固定的图像(不包括某些病态情况)。 HTML呈现的结果取决于此HTML以及浏览器窗口的大小和其他因素,例如视频卡属性和屏幕设置。如果您找到了一些用于执行此类转换的代码(可能您的意思是 http://code.google.com/p/ java-html2image / [ ^ ]) ,这意味着它需要HTML并使用一些额外的假设或附加信息。如果您不喜欢它的工作方式,请将其作为源代码,弄清楚它是如何工作的,并根据您的需要进行修改。任何人都不太可能自愿为你做这么奇怪的事情。



祝你好运,

-SA

I am trying to make a program which shows my favorite website as a desktop background but I am facing problem in converting HTML code to image.There is one API named htmltoimage on code.google.com but it doesn't work properly.I have searched lots of resource but there is no free API which can help me solve this problem.If you know any API or idea that can help me solve this problem, please let me know.

Thank you.

解决方案

You are "facing problem in converting HTML code to image" because there is not such "conversion" in principle.

Each fixed HTML does not produce any fixed image (excluding some pathological cases). The result on HTML rendering depends on this HTML and also on the size of the browser window and other factors, such as video card properties and screen settings. If you found some code for doing such "conversion" (probably you mean http://code.google.com/p/java-html2image/[^]), it means that it takes HTML and use some additional assumptions or additional information. If you don't like how it works, take it source code, figure out how it works and modify according to your needs. It's quite unlikely that anyone else would volunteer to do such pretty weird thing for you.

Good luck,
—SA


这篇关于如何使用java将HTML代码转换为Image?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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