PhantomJS不渲染本地存储的图像

时间:2014-09-22 02:05:52

标签: rendering phantomjs

我无法使用phantomjs正确渲染存储在我服务器中的图像。如果我使用互联网上存储的任何其他图像工作正常。所以我想知道是否有人可以告诉我一些我应该设置的服务器配置。

我有这个phantomjs脚本:

page.open(html, function () {

window.setTimeout(function( status ) {
    page.clipRect = { left: 0, top: 0, width: 640, height: 800 };
    page.render(outputFolder + htmlBaseName + '.png');
    console.log('rendered');
    phantom.exit();
}, 2000);

});

包含表格和这些图像的html文件:

<img src="http://myServerURL/image1.png" style="width: 198px; min-height: 181px; max-height: 181px; height: 181px; max-width: 198px;" width="198" height="181">
<img src="http://myServerURL/image2.png" style="width: 198px; min-height: 181px; max-height: 181px; height: 181px; max-width: 198px;" width="198" height="181">
<img src="http://phantomjs.org/img/phantomjs-logo.png" style="width: 198px; min-height: 181px; max-height: 181px; height: 181px; max-width: 198px;" width="198" height="181">

我得到的回报是:image

我的图片可以在互联网上查看

1 个答案:

答案 0 :(得分:0)

如果要在PDF中呈现本地图像,则必须将该图像转换为base-64,然后将此值传递到img标签的src属性中。

相关问题