Inserting SVG with parameters

Writing a book, Automating Document Production - Discuss your special needs here

Inserting SVG with parameters

Postby tridouble » Mon Sep 28, 2015 3:34 pm

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.
OpenOffice 4.1.1 on Windows XP
tridouble
 
Posts: 2
Joined: Mon Sep 28, 2015 3:21 pm

Re: Inserting SVG with parameters

Postby Villeroy » Mon Sep 28, 2015 4:22 pm

Which software is supposed to interprete these parameters? Where are your parameters specified?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26763
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Inserting SVG with parameters

Postby tridouble » Mon Sep 28, 2015 4:54 pm

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   Expand viewCollapse view
<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   Expand viewCollapse view
<object type="image/svg+xml" data="button.svg?color=red&outline=black"> </object>

This syntax is unterstood by most of browsers.
OpenOffice 4.1.1 on Windows XP
tridouble
 
Posts: 2
Joined: Mon Sep 28, 2015 3:21 pm

Re: Inserting SVG with parameters

Postby Villeroy » Mon Sep 28, 2015 6:05 pm

But this is an office suite and not a browser. For anything related to foreign file formats I would prefer LibreOffice over OpenOffice.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26763
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Advanced Uses

Who is online

Users browsing this forum: No registered users and 0 guests