【问题标题】:PhantomJS not rendering images stored locallyPhantomJS 不渲染本地存储的图像
【发布时间】:2014-09-22 02:05:52
【问题描述】:

我无法使用 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">

我得到了回报:

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

【问题讨论】:

标签: rendering phantomjs


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 1970-01-01
    • 2020-04-18
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多