Created
November 5, 2012 15:41
-
-
Save johnmay/4017856 to your computer and use it in GitHub Desktop.
CDK SVG Rendering with Batik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOMImplementation impl = GenericDOMImplementation.getDOMImplementation(); | |
Document document = impl.createDocument("http://www.w3.org/2000/svg", | |
"svg", | |
null); | |
// SVGGraphics2D implements java.awt.Graphics2D | |
SVGGeneratorContext context = SVGGeneratorContext.createDefault(document) | |
SVGGraphics2D g2 = new SVGGraphics2D(context, | |
true); // convert fonts to SVG Font glyphs | |
// render | |
renderer.paint(container, | |
new AWTDrawVisitor(g2), | |
new Rectangle(0, 0, size, size), | |
true); | |
g2.stream("/Users/johnmay/Desktop/sample.svg"); // write to a file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment