You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Sergei Rodionov <se...@axibase.com> on 2006/06/01 16:55:02 UTC
rasterizer problem
Hello,
In my server application I need to load an svg document on user request, parse it, modify
DOM and CSS styles and rasterize the svg document as jpeg.
It seems that I need to build a bridge context to enable dynamic DOM and CSS support.
It all works fine, but sometimes the code throws an NPE typical for cases when there is no
bridge context .
I looked at the GVTBuilder source ($Id: GVTBuilder.java,v 1.30 2005/03/27 08:58:30 cam Exp
$) , found these lines.
// <!> FIXME: TO BE REMOVED
if (ctx.isDynamic()) {
// register DOM listeners for dynamic support
ctx.addDOMListeners();
}
My environment JRE 1.4.2, Windows, batik 1.6
Thanks for any pointers!
======================================================
String svgURI = new File(path).toURL().toString();
SVGDOMImplementation domImpl = new SVGDOMImplementation();
SAXDocumentFactory f = new SAXDocumentFactory(domImpl,
"org.apache.xerces.parsers.SAXParser");
f.setValidating(false);
GZIPInputStream zIn = new GZIPInputStream(new FileInputStream(path));
Document res = f.createDocument("http://www.w3.org/2000/svg", "svg", svgURI, zIn);
UserAgent userAgent = new MyUserAgent();
DocumentLoader loader = new DocumentLoader(userAgent);
BridgeContext ctx = new BridgeContext(userAgent, loader);
ctx.setDynamicState(BridgeContext.DYNAMIC);
GVTBuilder builder = new GVTBuilder();
GraphicsNode gvtRoot = builder.build(ctx, res);