SVG scaleable?

S

Sascha Kerschhofer

Hi,

I wonder if SVG can be scaled, when embedded in a HTML Dokument like an
image with its width and height atributes.. Adobe SVG Viewer seems to crop
my SVG image when using width and height. Is there any solution?

Sascha Kerschhofer
 
K

Kevin Reid

Sascha Kerschhofer said:
Hi,

I wonder if SVG can be scaled, when embedded in a HTML Dokument like an
image with its width and height atributes.. Adobe SVG Viewer seems to crop
my SVG image when using width and height. Is there any solution?

Specify the 'viewBox' attribute on the 'svg' element.

The 'preserveAspectRatio' attribute may also be useful.
 
F

FC

Sascha Kerschhofer said:
Hi,

I wonder if SVG can be scaled, when embedded in a HTML Dokument like an
image with its width and height atributes.. Adobe SVG Viewer seems to crop
my SVG image when using width and height. Is there any solution?

Sascha Kerschhofer


Specify width='100%' height='100%' (or any other value of your choosing)
inside the main svg element, instead of using fixed values.
This will enable the scaling of graphics relative to the size of the window.

Bye,
Flavio
 
S

Sascha Kerschhofer

Thank You,

my HTML has this line
<OBJECT DATA="epm2.svg" WIDTH="100%" HEIGHT="100%" TYPE="image/svg+xml">

and my SVG has this
<svg width='100%' height='100%' version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">

Anyway my SVG is cropped in the browser window while it should be scaled to
fit 100% in the browser window. Please note, that dimensions of my svg are
unknown when creating the HTML code but are known when creating the SVG.
What am I doing wrong?

Sascha Kerschhofer
 
S

Sascha Kerschhofer

Sorry but when I set viewbox dimensions 10000 x 10000 Adobe SVG Viewer
displays my SVG very smal. I sugest the whole browser window has 10000 x
10000 units and whatever the dimensions of my drawing is it is scaled
correspondingly.

Sascha Kerschhofer
 
R

Rajya Sabha

Sascha said:
Sorry but when I set viewbox dimensions 10000 x 10000 Adobe SVG Viewer
displays my SVG very smal. I sugest the whole browser window has 10000 x
10000 units and whatever the dimensions of my drawing is it is scaled
correspondingly.

you can specify any values you like there. if you want your entire document to
be displayed, make sure the viewBox is big enough.

r.
 
F

FC

Sascha Kerschhofer said:
Sorry but when I set viewbox dimensions 10000 x 10000 Adobe SVG Viewer
displays my SVG very smal. I sugest the whole browser window has 10000 x
10000 units and whatever the dimensions of my drawing is it is scaled
correspondingly.

Sascha Kerschhofer

If you define a viewport 0 0 10000 10000 and the picture is 1000 x 1000, it
will be rendered using 10% of the available viewing frame.
On the other hand, if the viewport is 0 0 500 500, it will be clipped
because it doesn't fit, although you can pan (and zoom) using the mouse (at
least with Adobe SVG viewer).
Are you sure that you can't calculate roughly the size of the picture?
What's wrong with sizing the viewport to a "standard" 800x600 (or 1024 x
768) window and let the user pan over the hidden parts?

Bye,
Flavio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top