SVG Macro

This is a Radeox macro, bundled with all the XWiki products by default.
Macro developed by the XWiki Development Team.
This macro cannot currently be downloaded separately.

SVG Macro

The SVG macro allows to display SVG content as PNG images. It uses the SVGPlugin? internally to render the actual image.

Usage

{svg[:alternate text[|height[|width]]]}
svg content
{svg}

Parameters definition

NameOptionalAllowed valuesDefault valueDescription
texttrueany text The alternate text for the image, in case of a rendering error.
heighttruea strictly positive integer number400The height of the generated image.
widthtruea strictly positive integer number400The width of the generated image.

Content

The content must be a valid SVG image. It can be retrieved from an attachment using Velocity, as in:

{svg}${doc.getAttachment('image.svg').getContentAsString()}{svg}

Warning: Prior to XWiki Enterprise 2.0M1, if an xml prologue is used, it must begin exactly after the opening {svg} tag, without a newline, as otherwise the conversion will fail.

Example

{svg:The XWiki logo|100}<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
  viewBox="-57 -57 324 114" width="162" height="57" style="overflow: hidden">
  <style type="text/css">
    * {
      fill: none;
      stroke: #999;
      stroke-width: 7.5px;
      stroke-linecap: round;
      stroke-linejoin: round;
    }
    .X {
      stroke-width: 13px;
    }
    .wiki {
      stroke-width: 3px;
    }
  </style>
  <defs>
    <g id="dash" transform="translate(20 -20)">
      <path d="M 3 -3 L 14 -14"/>
    </g>
  </defs>
<use xlink:href="#dash" transform="rotate(-45)" class="north"/>
<use xlink:href="#dash" transform="rotate(45)" class="east"/>
<use xlink:href="#dash" transform="rotate(135)" class="south"/>
<use xlink:href="#dash" transform="rotate(-135)" class="west"/>
<line class="X" x1="-35" y1="-40" x2="35" y2="40"/>
<line class="X" x1="-35" y1="40" x2="35" y2="-40"/>
<path class="wiki" transform="translate(59 -41.5) scale(3.19)" d="M 0 0 L 5 26 14 0 23 26 28 0 M 33.5 0 V 26 M 40 0 V 26 M 55 0 L 42 13 55 26 M 60.5 0 V 26"/>
</svg>{svg}

This gives:

The XWiki logo

Tags:
Created by Sergiu Dumitriu on 2009/05/15 00:19
Last modified by Ecaterina Valic&#259; on 2009/10/16 14:11

This wiki is licensed under a Creative Commons license
2.2.1.27354