【问题标题】:how i can introduce a image into of PDF generated with weasyprint?如何将图像引入使用 weasyprint 生成的 PDF?
【发布时间】:2017-03-09 03:55:08
【问题描述】:

我可以使用 Django 和 weasyprint 生成 PDF,但是,我的 html 有问题,当我需要加载到图像时,我得到一个错误。我的实现是这样的:

This is my implementation

和我的html,我用简单的方式调用图像

"img src="{{ constancia.imagencita.url }} "

我得到“/media/firmas_directores_rrhh/180px-Walt_Disney_1942_signature.svg.png”(Pixbuf 错误:无法识别的图像文件格式)”

【问题讨论】:

    标签: html django weasyprint


    【解决方案1】:

    我能够使用带有“file:///”前缀的绝对文件路径作为 URL 来解决这个问题。

    没有什么不同:

    <img src="file:///path/to/file.png">
    

    【讨论】:

      猜你喜欢
      • 2018-03-26
      • 2020-02-01
      • 2015-05-25
      • 2021-08-23
      • 1970-01-01
      • 2014-07-15
      • 2016-01-11
      • 2020-11-12
      • 2019-11-08
      相关资源
      最近更新 更多