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 VA...@LILLY.COM on 2001/01/25 22:58:42 UTC
Rasterizing via API
Hi all,
I'm new to this list, so hopefully I'm not rehashing something that's
already been answered.
I am attempting to create a Servlet that will be able to transcode an
arbitrary SVG String into a PNG. I took a look at the source for the
command line rasterizer utility, and based my work from that. (my source
pasted below)
The "meat" of this servlet takes place in the writeImage method.
Unfortunately, when I run this, I get a "java.lang.NoSuchMethodError".
(pasted below also). I've taken a quick look through the affected
classes, but I am at a loss as to what is happening here (I'm not very
familiar with all the API's at work here yet)
Thanks,
Jason Vasquez
Source to the servlet:
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
String mimeType = "image/png";
res.setContentType(mimeType);
TranscoderFactory factory =
ConcreteTranscoderFactory.getTranscoderFactoryImplementation();
Transcoder t = factory.createTranscoder(mimeType);
String inputSVG = getSVG();
OutputStream os = res.getOutputStream();
writeImage(t, inputSVG, os);
os.flush();
os.close();
}
private void writeImage(Transcoder t, String svgInput,
OutputStream ostream) throws IOException{
InputSource isource = new InputSource(new
StringReader(svgInput));
//Buffer the output for performance
BufferedOutputStream bos = new
BufferedOutputStream(ostream);
t.transcodeToStream(isource, bos);
bos.flush();
}
The error message:
java.lang.NoSuchMethodError
at
org.apache.batik.dom.util.DocumentFactory.createDocument(DocumentFactory.java:108)
at
org.apache.batik.dom.svg.SVGDocumentFactory.createDocument(SVGDocumentFactory.java:59)
at
org.apache.batik.refimpl.transcoder.AbstractTranscoder.transcodeToStream(AbstractTranscoder.java:63)
at
com.lilly.cmit.analysis.client.web.PNGReportViewerServlet.writeImage(PNGReportViewerServlet.java:43)
at
com.lilly.cmit.analysis.client.web.PNGReportViewerServlet.doGet(PNGReportViewerServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Re: Rasterizing via API
Posted by Thierry Kormann <Th...@sophia.inria.fr>.
Hi,
VASQUEZ_JASON@LILLY.COM wrote:
> I am attempting to create a Servlet that will be able to transcode an
> arbitrary SVG String into a PNG. I took a look at the source for the command
> line rasterizer utility, and based my work from that. (my source pasted below)
Well, the current batik cvs base contains a new API for transcoders which must
be much easier to use and contains bug fixes. We hope to provide a new public
(development) release of batik in few days.
I propose that you will start working on this new version instead of the current
one which is (my fault) really not user-friendly.
Thanks for your comments,
Thierry.
--
Thierry Kormann
email: Thierry.Kormann@sophia.inria.fr http://www.inria.fr/koala/tkormann/
Koala/Dyade/Bull @ INRIA - Sophia Antipolis