Page 1 of 1

Inserting SVG with parameters

Posted: Mon Sep 28, 2015 3:34 pm
by tridouble
Hello,

Is it possible to insert a SVG file with parameters in a document ?
I tried the syntax pathtosvg?param1=value1 as url in the image property but it does not work.

Re: Inserting SVG with parameters

Posted: Mon Sep 28, 2015 4:22 pm
by Villeroy
Which software is supposed to interprete these parameters? Where are your parameters specified?

Re: Inserting SVG with parameters

Posted: Mon Sep 28, 2015 4:54 pm
by tridouble
The parameters are specified in the SVG file, as described at http://www.w3.org/TR/SVGParamPrimer/. They allow to customize the SVG (for instance the color).
An example of a SVG file named button.svg accepting 2 parameters :

Code: Select all

 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"  viewBox="0 0 110 40" width="100%" height="100%">
    <title>Button</title>
    <defs>
      <ref id="paramFill" param="color" default="blue"/>
      <ref id="paramStroke" param="outline" default="navy"/>
    </defs>
    <g>
      <rect id="button_rect" x="5" y="5" width="100" height="30" rx="15" ry="15" fill="url(#paramFill)" stroke="url(#paramStroke)" />
    </g>
  </svg>
To pass 2 parameters color and outline to button.svg the HTML syntax is :

Code: Select all

<object type="image/svg+xml" data="button.svg?color=red&outline=black"> </object>
This syntax is unterstood by most of browsers.

Re: Inserting SVG with parameters

Posted: Mon Sep 28, 2015 6:05 pm
by Villeroy
But this is an office suite and not a browser. For anything related to foreign file formats I would prefer LibreOffice over OpenOffice.