Inserting SVG with parameters

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
tridouble
Posts: 2
Joined: Mon Sep 28, 2015 3:21 pm

Inserting SVG with parameters

Post 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.
OpenOffice 4.1.1 on Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Inserting SVG with parameters

Post by Villeroy »

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 with LibreOffice 6.0, latest OpenOffice and LibreOffice
tridouble
Posts: 2
Joined: Mon Sep 28, 2015 3:21 pm

Re: Inserting SVG with parameters

Post 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.
OpenOffice 4.1.1 on Windows XP
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Inserting SVG with parameters

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply