xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@drexel.edu
Subject Pretty Printing/saving a nicely formatted Document
Date Tue, 25 May 2004 15:45:34 GMT
I save an SVG file and i would like for it to be formatted nicely... Here is my code some code
is left out to make things simple ... i wasnt sure how to add a PrettyPrinter as the code
i have commented out throws an exception...

    public static void saveXMLDocAsSVG(Document document) throws org.apache.batik.transcoder.TranscoderException{
        
        input = new TranscoderInput(svgCanvas.getSVGDocument());
        
        ////////////
        File f = JFileChooser to pick what to save it as.
        ////        
                try 
                {
                    writer = new PrintWriter(new FileOutputStream(f));
                }
                catch(FileNotFoundException e) {
                    e.getMessage();
                }
                catch(IOException e) {
                    e.getMessage();
                }
                
                try {
                    /*org.apache.batik.transcoder.svg2svg.PrettyPrinter newpp = new org.apache.batik.transcoder.svg2svg.PrettyPrinter();
                    newpp.print(input.getReader(), writer);
                    newpp.setTabulationWidth(5);
                    */
                     DOMUtilities.writeDocument( svgCanvas.getSVGDocument(), writer);
                }
                catch(IOException e) {
                    e.getMessage();
                }
                
                writer.flush();
                writer.close();
        
    }//end save


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message