Unbalanced Padding on SVG with out shadowing

0 votes
asked May 31, 2017 in Bug by anonymous
On a SVG image generated with out shadowing i.e.
for http://www.plantuml.com/plantuml/uml/AyxEp2j8B4hCLIZEI4p9By_CIrT8IymfJkNYAaXCpavCJrK8TlFrKQZcAafDBadCIyy12bGMbwJc8Wc4P-O1jI89k1Sb5cHa9XSZ2JcMfcJc8_7zKalAyukokMgv8COfsEZfmGo2K60Hk4b8gh29GOn74e2Q3m00
when the SVG result http://www.plantuml.com/plantuml/svg/AyxEp2j8B4hCLIZEI4p9By_CIrT8IymfJkNYAaXCpavCJrK8TlFrKQZcAafDBadCIyy12bGMbwJc8Wc4P-O1jI89k1Sb5cHa9XSZ2JcMfcJc8_7zKalAyukokMgv8COfsEZfmGo2K60Hk4b8gh29GOn74e2Q3m00
is embedded in a webpage, the main element has uneven padding (For visibility use a browsers developer tools to add the "border: 1px dashed #000;" to the svg elements style).
i.e. the frame has bounds of 22, 24, 372, 303 while the view port is set to 0, 0, 373, 304. This gives a left padding of 22 units, top padding of 24 units, and bottom and right padding of 1 units.
When requesting a png image, the left and right padding appear to be balanced.
commented Jun 1, 2017 by anonymous
I found a partial solution, for after inserting the SVG in to a HTML document using java script to fix the view box.

where svg is the svg dom element (taken from the document its inserted to otherwise getBBox dosen't seam to work)

var bb = svg.getBBox();
svg.setAttribute('viewBox', [bb.x, bb.y, bb.width, bb.height].join(" "));
svg.setAttribute('height', bb.height + "px");
svg.setAttribute('width', bb.width + "px");
svg.style.height = bb.height + "px";
svg.style.width = bb.width + "px";

However I suspect this would produce an unbalanced result if the shadow was used as the shadow would be part of the BBox, however I'm unsure of this and haven't tested it.

1 Answer

0 votes
answered Jun 1, 2017 by plantuml (257,860 points)
Thanks for the report.

This might have been solved in last beta:


Very few tests have been done, so tell us if it's ok for you.