DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document svgdocument = impl.createDocument(svgNS, "svg", null);
SVGGraphics2D g = new SVGGraphics2D(svgdocument);
g.setSVGCanvasSize(
new Dimension(base.getWidth(), base.getHeight()));
//g.setColor(Color.white);
//g.fillRect(0, 0, base.getWidth(), base.getHeight());
g.setColor(Color.black);
base.paint(g);
//if (antialiasing)
//element.setAttribute("text-rendering", "optimizeLegibility");
//else
//element.setAttribute("text-rendering", "geometricPrecision");
// this should be done in a better way
Element root = g.getRoot();
svgdocument = impl.createDocument(svgNS, "svg", null);
Node node = svgdocument.importNode(root, true);
((org.apache.batik.dom.svg.SVGOMDocument) svgdocument).
getRootElement().appendChild(node);