By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,375 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,375 IT Pros & Developers. It's quick & easy.

SVG scaleable?

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Sascha Kerschhofer <sk**********@yahoo.de> wrote:
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.

--
Kevin Reid
Jul 20 '05 #2

P: n/a
FC

"Sascha Kerschhofer" <sk**********@yahoo.de> wrote in message
news:bf**********@news.mch.sbs.de...
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
Jul 20 '05 #3

P: n/a
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
"FC" <fl****@tin.it> schrieb im Newsbeitrag
news:Or*********************@news2.tin.it...

"Sascha Kerschhofer" <sk**********@yahoo.de> wrote in message
news:bf**********@news.mch.sbs.de...
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

Jul 20 '05 #4

P: n/a
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

"Rajya Sabha" <ra****@uboot.com> schrieb im Newsbeitrag
news:3f********@news.arcor-ip.de...
Sascha Kerschhofer wrote:
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?

add a viewBox attribute to the svg element and make it large enough to

cover your drawing.
( viewBox="0 0 10000 10000" ) should be fine.

kevin posted this already.

r.

Jul 20 '05 #5

P: n/a
FC

"Sascha Kerschhofer" <sk**********@yahoo.de> wrote in message
news:bf**********@news.mch.sbs.de...
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
Jul 20 '05 #6

P: n/a
Sascha Kerschhofer wrote:
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.

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.