Skip to content

Commit

Permalink
For #23 - Copy across attributes on the SVG element such as viewBox.
Browse files Browse the repository at this point in the history
@rototor - The SVG example is now working perfectly including text,
sizing and positioning. Custom fonts via the font-face rule are also
working.
  • Loading branch information
danfickle committed Feb 13, 2017
1 parent eaf1129 commit a32edb8
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public void drawSVG(Element svgElement, OutputDevice outputDevice, RenderingCont
newDocument.getDocumentElement().appendChild(importedNode);
}

// Copy attributes such as viewBox to the new SVG document.
for (int i = 0; i < svgElement.getAttributes().getLength(); i++) {
Node importedAttr = svgElement.getAttributes().item(i);
newDocument.getDocumentElement().setAttribute(importedAttr.getNodeName(), importedAttr.getNodeValue());
}

if (svgElement.hasAttribute("width")) {
newDocument.getDocumentElement().setAttribute("width", svgElement.getAttribute("width"));
}
Expand Down

1 comment on commit a32edb8

@rototor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thank you!

Please sign in to comment.