【问题标题】:xhtml2pdf does not show image alwaysxhtml2pdf 不总是显示图像
【发布时间】:2013-05-08 16:37:41
【问题描述】:

我使用 xhmtl2pd 工具将 html 转换为 pdf。这是我的一段html

<tr>
    <td style="width:10px;vertical-align:top">&bull; </td>
    <td style="padding:0 0 5px 0;width:200px;display:inline-block">
        blah blah <br/>              
        <img src="images/little-gray-arrow.png" height="10" width="11" alt="blah" /> 
    </td>
</tr>

奇怪的是,如果我删除了 br 标签,那么 little-gray-arrow.png 的图像就永远不会出现。把 br 标签放回去,图像显示在“下一个”行。 我已经尝试了所有选项,填充,边距,但没有任何效果。

我还尝试在文本之间内联显示图像,并且无论我尝试什么,图像 clock.png 的下半部分总是被切断。

<tr>
    <td style="width:10px;vertical-align:top">&bull; </td>
    <td style="padding:0 0 5px 0;width:200px;">
        Wait
        <img src="images/clock.png" height="20" width="20" alt="20" />
        minutes
    </td>
</tr>

有谁知道如何解决这个问题,这就是 xhmtl2pdf 的方式。 xhtml2pdf可以内联显示图片吗?

谢谢

【问题讨论】:

    标签: image xhtml2pdf


    【解决方案1】:

    不要在 url 或 src 中使用绝对路径。使用像 https://abcd.com/.../image.png 这样的完整路径。它对我有用

    【讨论】:

      【解决方案2】:

      如果您需要 GIF 或 PNG 等渲染图像格式,则应安装 PIL library。 ReportLab 需要 Python 图像库 (PIL) 来处理 PNG/GIF 图像。

      参考:Output image to pdf with xhtml2pdf

      【讨论】:

        猜你喜欢
        • 2013-07-03
        • 2021-03-20
        • 2015-01-09
        • 1970-01-01
        • 1970-01-01
        • 2021-02-25
        • 1970-01-01
        • 2015-07-06
        • 2017-06-05
        相关资源
        最近更新 更多