xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francois RAJCHENBACH" <francois.rajchenb...@RTE-FRANCE.COM>
Subject Batik not working in an applet
Date Tue, 24 Apr 2007 14:56:48 GMT
Hi all.

I'm trying to develop an applet that uses Batik's PrintTranscoder and 
Java's Print Service to print a SVG file. I'm using Batik 1.6 and Java 
1.4.2_07. Here is the code of a public method of my applet:


        public void printSvgFromUrl(String inUrl, String inPrinterName) {
                try {
 
XMLResourceDescriptor.setXMLParserClassName("org.apache.xerces.parsers.SAXParser");
                        String tmpAbsoluteUrl = (new 
URL(this.getDocumentBase(), inUrl)).toString();
                        TranscoderInput tmpInput = new 
TranscoderInput(tmpAbsoluteUrl);
                        PrintTranscoder tmpPrintable = new 
PrintTranscoder();
                        tmpPrintable.transcode(tmpInput, null);
                        HashPrintServiceAttributeSet tmpPrinterAttributes 
= new HashPrintServiceAttributeSet();
                        tmpPrinterAttributes.add(new 
PrinterName(inPrinterName, null));
                        PrintService tmpPrinter = 
PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, 
null)[0];
                        HashDocAttributeSet tmpDocAttributes = new 
HashDocAttributeSet();
                        tmpDocAttributes.add(MediaSizeName.ISO_A4);
                        Doc tmpDoc = new SimpleDoc(tmpPrintable, 
DocFlavor.SERVICE_FORMATTED.PRINTABLE, tmpDocAttributes);
                        DocPrintJob tmpJob = tmpPrinter.createPrintJob();
                        tmpJob.print(tmpDoc, null);

                } catch (Throwable e) {
                        e.printStackTrace();
                }
        }

When I call this method from JavaScript, I get the following stack trace:

java.io.IOException: SAX2 driver class org.apache.xerces.parsers.SAXParser 
not found
        at 
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown 
Source)
        at 
org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown 
Source)
        at 
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown 
Source)
        at 
org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown 
Source)
        at 
org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown 
Source)
        at 
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown 
Source)
        at org.apache.batik.transcoder.print.PrintTranscoder.print(Unknown 
Source)
        at sun.print.RasterPrinterJob.printPage(Unknown Source)
        at sun.print.RasterPrinterJob.print(Unknown Source)
        at sun.print.Win32PrintJob.printableJob(Unknown Source)
        at sun.print.Win32PrintJob.print(Unknown Source)
        at com.rte.onpage.print.OnpagePrintAgent.printSvgFromUrl(Unknown 
Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
        at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
        at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
        at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

I put xerces_2_5_0.jar in the archive attribute of the applet tag inmy web 
page. Can anyone tell me what's wrong ? Thank you in advance.

Best regards.

Fran├žois
Mime
View raw message