views:

222

answers:

1

Hello !

I have a svg file of 100x100 pixels (for example). I am using Batik.

If I do a :

JSVGCanvas svg = new JSVGCanvas();
[...]
svg.setSize(10,10);

It will only show this part of the picture and not the resized image.

Do you know how I can display a resized svg picture ?

Thanks ;)

A: 

You need to ensure that the document you are displaying has a viewBox="" attribute set on its root <svg> element. For example, specifying viewBox="100 100 300 200" indicates that the region (100,100)→(400,300) will be scaled to the size of the JSVGCanvas. By default, the aspect ratio of this region will be preserved when scaling, so you will get some extra padding on the top or bottom if it doesn't match the aspect ratio of your JSVGCanvas. To override that behaviour, use the preserveAspectRatio="" attribute.

heycam