Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support referenced SVG images #137

Closed
CWempe opened this issue Jun 11, 2021 · 8 comments
Closed

Support referenced SVG images #137

CWempe opened this issue Jun 11, 2021 · 8 comments

Comments

@CWempe
Copy link

CWempe commented Jun 11, 2021

I am using asciidoctor to create PDFs.
I created an SVG file for the title page of my document.
This SVG file has two other images referenced like this:

    <image
       preserveAspectRatio="none"
       inkscape:svg-dpi="512"
       width="33.599998"
       height="33.599998"
       style="image-rendering:optimizeQuality"
       xlink:href="my_image.svg"
       id="image8061"
       x="23.083784"
       y="239.09735" />

This does not work because prawn-svg does not support linked SVG files in a SVG file.
It works when I change it to PNG.

       xlink:href="my_image.png"

It would be great if prawn-svg would support this.

I initially created an issue here: asciidoctor/asciidoctor-pdf#1937

@mogest
Copy link
Owner

mogest commented Jun 11, 2021 via email

@mojavelinux
Copy link
Contributor

Interesting. I was not aware of that. I suppose it would be possible in Asciidoctor PDF to rewrite the target automatically.

Is there a reason that the relative path cannot be supported? Just curious.

@mogest
Copy link
Owner

mogest commented Jun 11, 2021 via email

@mogest
Copy link
Owner

mogest commented Jun 11, 2021 via email

@mojavelinux
Copy link
Contributor

I'll see if someone in the community is available to contribute.

@Alwinator
Copy link

I would need this feature too since asciidoctor-diagram (with graphviz) generates this syntax when you use an SVG for a node. I am not a Ruby programmer, but I think instead of skipping the element it should be replaced with the raw SVG code.

raise SkipElementError, "Unsupported image type supplied to image tag; Prawn only supports JPG and PNG"

@mogest
Copy link
Owner

mogest commented Mar 18, 2022

Sadly it's not that straight forward @Alwinator. The SVG has its own context and view box; things that happen in the main SVG shouldn't affect things in the embedded SVG, and it has to be scaled correctly. It shouldn't be super hard to implement, but it's definitely not as simple as just copying the SVG code inline.

mogest added a commit that referenced this issue Jan 28, 2024
This allows <image> elements to reference SVG documents so they can be
embedded inside the top-level SVG document.

Implements #137 and #144
@mogest
Copy link
Owner

mogest commented Jan 28, 2024

A couple years late but better late than never :)

@mogest mogest closed this as completed Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants