我正在尝试使用 npm 将此页面呈现wkhtmltox
为 png:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
html, body {
padding: 0;
width: 340px;
}
html, body, dl {
margin: 0;
font-size: 11px;
font-family: Verdana, Arial;
background-color: #fff;
}
dl {
padding: 5px;
width: 330px;
}
dt {
float: left;
clear: left;
width: 80px;
text-align: right;
color: #1d439b;
}
dd {
width: 240px;
margin: 0 0 0 90px;
padding-bottom: 0.5em;
}
</style>
</head>
<body>
<dl>
<dt>eargasm</dt><dd>Audio (music/effects/foley) is outstanding.</dd>
<dt>中文</dt><dd>My favourite language (mandarin chinese).</dd>
<dt>eyegasm</dt><dd>Mind-blowingly stunning visuals.</dd>
</dl>
</body>
</html>
我只是像平常一样渲染这个:
converter.image(fs.createReadStream('tagslegend.html'), { format: "png" }).pipe(response);
我得到这样的图像:
它的宽度为 1024 像素。
我期待一个 340 像素宽的图像。