gui.ava.html.Html2Image无法呈现文本溢出

时间:2018-06-22 13:43:33

标签: java html

我正在尝试使用gui.ava.html.Html2Image类将动态生成的HTML转换为Image。我得到了图像,但是看到了某些属性,例如“ text-overflow:省略号”。和“ box-sizing:border-box;”转换为图像时无法理解。我生成的HTML在所有浏览器上都可以。但是Html2Image会忽略这些属性。

HTML(test.html)是:

<!DOCTYPE html>
<html>
<head>
<style> 
div.a {
    white-space: nowrap; 
    width: 100px; 
    overflow: hidden;
    text-overflow:ellipsis;
    border: 1px solid #000000;
}

div.a:hover {
    overflow: visible;
}
</style>
</head>
<body>
<h1>The text-overflow Property</h1>

<p>Hover over the div below, to see the entire text.</p>

<div class="a">This is some long text that will not fit in the box.</div>

</body>
</html>

代码段为:

Html2Image generator = Html2Image.fromFile(new File("test.html"));
final ImageRenderer imageRenderer = generator.getImageRenderer();
imageRenderer.saveImage(new File("test.png"));

0 个答案:

没有答案