【问题标题】:Embedded jpeg showing in svg, but not in pdf when generated with svglib, reportlab嵌入的 jpeg 在 svg 中显示,但在使用 svglib、reportlab 生成时不显示在 pdf 中
【发布时间】:2011-10-06 01:04:25
【问题描述】:

我正在使用 0.6.3 版的 svglib 和 reportlab 2.5。 我在 Inkscape 中创建了测试 svg;放一张jpeg,嵌入base64。

当我进入代码时,jpeg 在 svglib 中生成,但它从未出现在 pdf 中。

矢量形状可以正常工作并显示,但缺少 jpeg。我在终端(svg2pdf)中使用基本命令进行测试。

有人遇到过类似的问题吗?

编辑: SVG 代码,根据要求:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="744"
height="1052"
id="svg2"
version="1.1">
<defs
id="defs4" />
<rect width="1000" height="1000"
style="fill:rgb(0,0,255);stroke-width:1;
stroke:rgb(0,0,0)"/>
<image
y="378"
x="282"
id="image2993"
xlink:href="data:image/jpeg;base64,/9j/4AAQSk... snip snip .../9k="
height="307"
width="186" />
</svg>

【问题讨论】:

    标签: python django pdf svg


    【解决方案1】:

    如果没有更多细节,这很难回答,但最常见的错误是,包含图像时不包含命名空间:

    <image href="someurlgoeshere" x="0" y="0" height="10" width="10"></image>
    

    <image xlink:href="someurlgoeshere" x="0" y="0" height="10" width="10"></image>
    

    【讨论】:

    • 我有命名空间(下面的例子是正确的)所以没有问题。
    • 当您说您使用的是 base64 时,我假设您使用的是 dataurl。它是否开始像这样:xlink:href="data:image/jpeg;base64,abunchofbasesixtyfourstuffgoeshere"
    • 你能发布 SVG 代码吗? SVG->PDF 中还有许多其他常见问题会出现。
    猜你喜欢
    • 2010-11-15
    • 2012-02-09
    • 2011-10-23
    • 1970-01-01
    • 2013-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多