[solved] how to add viewBox to inkscape document

Post questions on how to use or achieve an effect in Inkscape.
User avatar
capnhud
Posts: 435
Joined: Mon Jun 04, 2007 8:30 pm
Location: U.S.A

[solved] how to add viewBox to inkscape document

Postby capnhud » Sat Apr 19, 2008 9:51 am

I am not very fluent in svg markup and wanted to know when I look at an inkscape document where would I add viewBox in this intial markup so that the svg scales in a browser.

Code: Select all

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="744.09448819"
   height="1052.3622047"
   id="svg2"
   sodipodi:version="0.32"
   inkscape:version="0.46"
   sodipodi:docname="test.svg"
   inkscape:output_extension="org.inkscape.output.svg.inkscape">

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: how to add viewBox to inkscape document

Postby sas » Sat Apr 19, 2008 6:34 pm

You can put viewBox="0 0 744.09448819 1052.3622047" where you currently have the width and height lines. (I think you need to remove the width and height lines to make it scale in most browsers.)

If you're making a copy for the web, it's usually also a good idea to save it as Plain SVG.

User avatar
capnhud
Posts: 435
Joined: Mon Jun 04, 2007 8:30 pm
Location: U.S.A

Re: how to add viewBox to inkscape document

Postby capnhud » Sat Apr 19, 2008 10:12 pm

I noticed that you included two zero's before the width and height, why was that necessary?

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: how to add viewBox to inkscape document

Postby sas » Sat Apr 19, 2008 10:46 pm

viewBox is always a list of four numbers. The first two numbers are the minimum x and y coordinates, and the other two are the width and height. If you're adding a viewBox to an SVG file that didn't previously have one, then the minimum x and y values should be 0 (unless you're trying to change the image borders).

User avatar
capnhud
Posts: 435
Joined: Mon Jun 04, 2007 8:30 pm
Location: U.S.A

Re: how to add viewBox to inkscape document

Postby capnhud » Sun Apr 20, 2008 10:13 pm

Ok you explained very well thank you. I wish this was something you could automatically add to a document in inkscape, but I can take the extra time to ensure that it is there.

User avatar
microUgly
Site Admin
Posts: 2985
Joined: Sat Jun 02, 2007 3:13 pm
Contact:

Re: how to add viewBox to inkscape document

Postby microUgly » Mon Apr 21, 2008 9:16 am

It would definitely to have this as an option in the document properties. Perhaps you could request it on Launchpad if it hasn't already been requested.


Return to “Help with using Inkscape”