xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From VASQUEZ_JA...@LILLY.COM
Subject Rasterizing via API
Date Thu, 25 Jan 2001 21:58:42 GMT
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)

Mime
View raw message