Calculating the size of an SVG image

During composition, TopLeaf reads the SVG to determine its size. It scans the file for an <svg> tag that either has both the width and height attributes, or has the viewBox attribute. Note that if you have nested svg elements and the outermost one does not specify a size, TopLeaf will calculate an incorrect size. SVG images of this form are not suitable for use by TopLeaf.

If both the width and height attributes are present, TopLeaf will use them to calculate a natural size for the graphic (see Image Size in the Mapping Guide). For this purpose, any unit that does not have a constant size (for example, pixels) will be treated as points. This means that “72px”, “72pt” and “1in” all produce the same result (one inch).

When either or both of the width and height attributes are missing, TopLeaf uses the width and height values in the viewBox attribute. These are always interpreted as a number of points. The “x” and “y” components of the viewBox value are ignored.