Skip to content

Instantly share code, notes, and snippets.

@johnmay
Created November 5, 2012 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmay/4017856 to your computer and use it in GitHub Desktop.
Save johnmay/4017856 to your computer and use it in GitHub Desktop.
CDK SVG Rendering with Batik
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