How to output SVG from an extension that will be rendered in PDF?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to output SVG from an extension that will be rendered in PDF?

wimdeblauwe
Hi,

I have created a BlockProcessor that outputs SVG and this renders in the HTML5 backend. However, it is not rendered when creating a PDF.

This is my process method:

public Object process(AbstractBlock parent, Reader reader, Map<String, Object> attributes) {
        return createBlock(parent, "pass", "<svg width=\"100\" height=\"100\">\n" +
                "  <circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"green\" stroke-width=\"4\" fill=\"yellow\" />\n" +
                "</svg>", attributes, new HashMap<>());
    }

I just tried with the built-in SVG support and that renders in all used modes in PDF as well. I tried with this:

This is an SVG from a file:

image::sample.svg[]

This is an SVG from a file in 'interactive' mode:

[%interactive]
image::sample.svg[]

This is an SVG from a file in 'inline' mode:

[%inline]
image::sample.svg[]

Is it possible to re-use that support when adding SVG from an extension? How would I do that?

regards,

Wim
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to output SVG from an extension that will be rendered in PDF?

mojavelinux
Administrator
You need to return an image block if you want to create a portable image node.

createBlock(parent, "image", ...)

You need to pass a list of attributes that includes "alt" and "target" at a minimum.

-Dan

On Wed, Jul 19, 2017 at 5:58 AM, wimdeblauwe [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

I have created a BlockProcessor that outputs SVG and this renders in the HTML5 backend. However, it is not rendered when creating a PDF.

This is my process method:

public Object process(AbstractBlock parent, Reader reader, Map<String, Object> attributes) {
        return createBlock(parent, "pass", "<svg width=\"100\" height=\"100\">\n" +
                "  <circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"green\" stroke-width=\"4\" fill=\"yellow\" />\n" +
                "</svg>", attributes, new HashMap<>());
    }

I just tried with the built-in SVG support and that renders in all used modes in PDF as well. I tried with this:

This is an SVG from a file:

image::sample.svg[]

This is an SVG from a file in 'interactive' mode:

[%interactive]
image::sample.svg[]

This is an SVG from a file in 'inline' mode:

[%inline]
image::sample.svg[]

Is it possible to re-use that support when adding SVG from an extension? How would I do that?

regards,

Wim


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/How-to-output-SVG-from-an-extension-that-will-be-rendered-in-PDF-tp5745.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Loading...