Skip to main content
Known Participant
December 1, 2016
Answered

SVG - viewBox

  • December 1, 2016
  • 1 reply
  • 6451 views

Hi,

I'm wondering if someone can clear this up for me? I've got a very simple file of a 400x400px Artboard with a single rectangle in it. When you copy a shape to your clipboard in Illustrator you get something like:

<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In  -->

<svg version="1.1" baseProfile="basic"

     xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"

     x="0px" y="0px" width="141.7px" height="129.6px" viewBox="0 0 141.7 129.6" style="enable-background:new 0 0 141.7 129.6;"

     xml:space="preserve">

<style type="text/css">

    .st0{fill:#FFFFFF;stroke:#000000;stroke-miterlimit:10;}

</style>

<defs>

</defs>

<rect x="0.5" y="0.5" class="st0" width="140.7" height="128.6"/>

</svg>

If you, using the same file/shape, go Save As... > Set Format to SVG (svg) > Hit Save > In the SVG Options hit 'SVG Code...'

You get:

<?xml version="1.0" encoding="utf-8"?>

<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->

<svg version="1.1" baseProfile="basic" id="Layer_1"

  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 400 400"

  xml:space="preserve">

<rect x="126.5" y="105" fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" width="140.7" height="128.6"/>

</svg>

What I'm interested in here is the viewBox attribute. On the clipboard this is set to viewBox="0 0 141.7 129.6" (i.e. the bounds of the shape(s)) but on the export you get viewBox="0 0 400 400" (i.e. the size of the artboard).

I've tried the different CSS Properties but it seems it's not possible to copy the Artboard size (viewBox) to the clipboard without going via Save As... Does anyone know any different?

Thanks,

Chris

Illustrator CC2017

OSX 10.11.6

Correct answer Monika Gause

What I'M referring to is that the artboard is independent from object hierarchy. It doesn't get copied to the clipboard and therefore its size is simply not there to do calculations with it.

1 reply

Monika Gause
Community Expert
Community Expert
December 1, 2016

The artboard doesn't get copied.

Known Participant
December 1, 2016

I will take your word for it.

Monika Gause
Community Expert
Monika GauseCommunity ExpertCorrect answer
Community Expert
December 1, 2016

What I'M referring to is that the artboard is independent from object hierarchy. It doesn't get copied to the clipboard and therefore its size is simply not there to do calculations with it.