asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 500 forks source link

SVG not rendered correctly #2472

Closed manuel-rubio closed 7 months ago

manuel-rubio commented 7 months ago

I'm using asciidoctor-pdf to generate a document with the attached SVG image, the problem is that the image is rendered in the page as showed in the second attached screenshot, it's not happening with other SVG images I've only with this one, and this one is perfectly showed in Google Chrome and Gimp.

Asciidoctor PDF 2.3.9 using Asciidoctor 2.0.20 [https://asciidoctor.org] Runtime Environment (ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

Code I use to put the image in the document:

[#fig-algol]
.Las ramas de ALGOL
image::algol_legacy.svg["Las ramas de ALGOL",align=center,scale=20]

algol_legacy

image
mojavelinux commented 7 months ago

Asciidoctor PDF uses prawn-svg to render the SVG. prawn-svg only supports pure SVG. Browsers allow HTML to be mixed with SVG, which is technically non-standard and also browser-dependent. That's why it works in the browser, but not in Asciidoctor PDF.

If there's ever an issue with rendering SVG, you will need to direct that issue to the prawn-svg project. Asciidoctor PDF doesn't handle the rendering itself, but rather delegates to this library. So if a feature of SVG isn't supported by prawn-svg, it won't be supported in Asciidoctor PDF either.

mojavelinux commented 7 months ago

That's why it works in the browser, but not in Asciidoctor PDF.

In this case, I'm not detecting any embedded HTML. That means there is a chance that prawn-svg should be able to render this SVG correctly. However, it may be messing up the CSS somewhere. I think it's still work filing an issue in that project to see what the maintainer has to say about it.

mojavelinux commented 7 months ago

and Gimp.

Gimp is not an SVG editor. You should be using Inkscape (or some other vector program instead).

If I open this SVG in Inkscape, I see only black boxes. That tells me there's something about this SVG that is non-standard. Or perhaps it has to do with this parsing error:

parsing error: 1:8265:could not recognize next production
parsing error: 1:8280:while parsing rulset: current char must be a '}'
parsing error: 1:8279:while parsing declaration: next property is malformed
manuel-rubio commented 7 months ago

@mojavelinux Indeed it was generated by Mermaid Mindmap, I guess I'll move the issue there. Thanks.