Reuse element groups (that are other svg images) in batik generated svg

34 Views Asked by At

When generating svg with batik some elements are put in defs and reused. But in my case i have many element groups I could reuse that are actually other svg images drawn on screen eg:

    <g fill="url(#b3)" font-family="'Segoe UI'" stroke="url(#b3)" text-rendering="geometricPrecision" transform="translate(56,24) matrix(0.6667,0,0,0.6667,0,0)">
      <rect clip-path="url(#b4)" height="17" stroke="none" width="21" x="1.5" y="3.5"/>
    </g>
<...>
    <g fill="rgb(66,66,66)" font-family="'Segoe UI'" stroke="rgb(66,66,66)" stroke-linecap="butt" text-rendering="geometricPrecision" transform="matrix(0.6667,0,0,0.6667,56,24)">
      <line clip-path="url(#b4)" fill="none" x1="22.5" x2="1.5" y1="17.5" y2="17.5"/>
    </g>

I would like something like that defined in defs and then reused with:

 <use xlink:href="#cube" transform="translate(56,43) matrix(0.6667,0,0,0.6667,0,0)"/>

Note that original group mixes matrix and matrix+translate, in my experiments I can do same or merge both into matrix for whole group in .

Any way to do that with batik, or will I need to write my own xml parser+optimizer?

Tried reading and debugging through batik but could not find a way to reuse such groups.

0

There are 0 best solutions below