Skip to content

SVG broken when converting Markdown to PDF with WeasyPrint #11275

@r4f

Description

@r4f

Explain the problem.
Failure of producing an image from an SVG in the resulting PDF.
The problem only appears with Pandoc 3.8, but not for Pandoc 3.5-3.7.

pandoc -o output.pdf document.md --pdf-engine weasyprint

results in a PDF with the alt text in the place of the SVG image.
Pandoc outputs the following error message (base64 content shortened by me):

ERROR: Failed to load image at 'data:application/pdf;base64,JVBERi0xL[...]U9GCg==':
UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f7b7ba18270>

which I have not yet made sense of.

The markdown file was

# A markdown file with an svg image.

![svg image](image.svg)

and the SVG is the first example in https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorials/SVG_from_scratch/Getting_started.

I have created a gist https://gist.github.com/r4f/b110e76f21173e004235cdca6a9421fb which lets you conveniently execute a docker-compose command to demonstrate that the problem is present in Pandoc 3.8, while a second docker-compose command demonstrates that the issue did not appear with Pandoc 3.7. (See the README of the gist for the exact commands)

Pandoc version?
3.8.2.1 (the latest release as of writing, on Ubuntu, as provided in the Docker image)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions