[xwiki-users] rendering SVG graphics in XWiki documents
Hello, I did search what I possibly could but could not find a way to attach an SVG file to a document and have this image rendered in it. Is this doable? I found that there is SVG plugin (enabled) in the xwiki.cfg but could not find any documentation on how to use it. (this is on XWiki 1.9-m2) Kind regards, Vlad
Vladimir Konrad wrote:
Hello,
I did search what I possibly could but could not find a way to attach an SVG file to a document and have this image rendered in it.
Is this doable?
I found that there is SVG plugin (enabled) in the xwiki.cfg but could not find any documentation on how to use it.
(this is on XWiki 1.9-m2)
Check http://code.xwiki.org/xwiki/bin/view/Macros/SVGMacro (this works with documents in the xwiki/1.0 syntax). If you want to do something similar in 2.0 syntax, you should use: {{velocity}} {{html}}<img src="${xwiki.svg.getSVGImageURL(${doc.getAttachment('logo.svg').getContentAsString()}, 100, 100)}" width="100" height="100" alt="The logo" />{{/html}} {{/velocity}} -- Sergiu Dumitriu http://purl.org/net/sergiu/
On May 15, 2009, at 1:27 AM, Sergiu Dumitriu wrote:
Vladimir Konrad wrote:
Hello,
I did search what I possibly could but could not find a way to attach an SVG file to a document and have this image rendered in it.
Is this doable?
I found that there is SVG plugin (enabled) in the xwiki.cfg but could not find any documentation on how to use it.
(this is on XWiki 1.9-m2)
Check http://code.xwiki.org/xwiki/bin/view/Macros/SVGMacro (this works with documents in the xwiki/1.0 syntax).
If you want to do something similar in 2.0 syntax, you should use:
{{velocity}} {{html}}<img src="${xwiki.svg.getSVGImageURL($ {doc.getAttachment('logo.svg').getContentAsString()}, 100, 100)}" width="100" height="100" alt="The logo" />{{/html}} {{/velocity}}
Note that in the near future you'll be able to write: {{velocity}} [[image:${xwiki.svg.getSVGImageURL($ {doc.getAttachment('logo.svg').getContentAsString()}, 100, 100)}>>width="100" height="100" alt="The logo"]] {{/velocity}} And you'll also be able to create macros from wiki pages easily just you'll be able to create your own {{svg}} macro. Of course we'll probably just provide an svg macro in the default distribution... :) Thanks -Vincent
Hello Sergiu,
If you want to do something similar in 2.0 syntax, you should use:
{{velocity}} {{html}}<img src="${xwiki.svg.getSVGImageURL(${doc.getAttachment('logo.svg').getContentAsString()}, 100, 100)}" width="100" height="100" alt="The logo" />{{/html}} {{/velocity}}
I have tried the above (the page is in 2.0 syntax), but for some reason I could not get this work correctly (the .svg did way too much empty space around it), possibly the "bounding box" issue or something like that. For the time being, I went with .png (converted from .svg) but it is good to know that better support for SVG is being worked on. Kind regards, Vlad
participants (3)
-
Sergiu Dumitriu -
Vincent Massol -
Vladimir Konrad