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 John Greene <jo...@rpiwireless.com> on 2003/08/09 12:24:14 UTC

SVGDocument to document.svg --- HOW?

I have an object of class SVGDocument.
I want to stream it to a file.
How do you turn an SVGDocument object into an SVG file?
(no joy with SVGGraphics2D so far.)



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


Re: SVGDocument to document.svg --- HOW?---**THIS WORKS

Posted by John Greene <jo...@rpiwireless.com>.
This method will write an SVG document.

-----------------------------------

 public static void writeSVGFile(){
        SVGDocument document=Public.uIMan.getActiveViewer().getSVGDoc();
        File file=new File("c:/a2/eatme.svg");
        try{
            FileWriter writer=new FileWriter(file);
            DOMUtilities.writeDocument(document,writer);
            writer.flush();
            writer.close();   
        }catch(Exception e){System.out.println(e);}}

--------------------------------------

NOTE: Don't forget the flush and close otherwise the writer will leave 
off the end of your document (and your viewer will choke).



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


Re: SVGDocument to document.svg --- HOW?

Posted by John Greene <jo...@rpiwireless.com>.
>
> What is Squiggle's complaint?  Can you provide a sample file?

it turned out to be a writer issue. Gotta flush. See my other post on 
this subject reporting my huge success.



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


Re: SVGDocument to document.svg --- HOW?

Posted by Thomas DeWeese <Th...@Kodak.com>.
John Greene wrote:
>   John Greene wrote:
> 
>>> I have an object of class SVGDocument.
>>> I want to stream it to a file.
>>> How do you turn an SVGDocument object into an SVG file?
>>> (no joy with SVGGraphics2D so far.)
>>
>>
>> Hi John,
>>
>>    Check out batik.dom.util.XMLUtilities.writeNode
>> or batik.svggen.XMLWriter
>>
> I'm using Batik-1.5
> I see no *XMLUtilities* class in the *org.apache.batik.dom.util* package
> (There's a* DOMUtilities* class, with a *writeDocument* method (and a 
> *writeNode* method which I have yet to experiment with), which generated 
> some code that looked nice but the Squiggle viewer refused to accept so 
> I suppose it was invalid SVG).
> I also see no *XMLWriter* class in my *org.apache.batik.svggen* package.
> What library are you using?

    Sorry if you spent some time hunting, I was going from memory.
DOMUtilities is the class I was thinking of from dom.util (and
writeDocument is probably better than writeNode).

What is Squiggle's complaint?  Can you provide a sample file? It's
possible the SVGDocument is invalid to start with or more likely
some things like the xmlns attributes are missing
(things not really needed for DOM but needed for Xml).

    There _is_ an XmlWriter class in batik.svggen (case was wrong in my
first response).



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


Re: SVGDocument to document.svg --- HOW?

Posted by Thomas DeWeese <Th...@Kodak.com>.
John Greene wrote:
> I have an object of class SVGDocument.
> I want to stream it to a file.
> How do you turn an SVGDocument object into an SVG file?
> (no joy with SVGGraphics2D so far.)

Hi John,

    Check out batik.dom.util.XMLUtilities.writeNode
or batik.svggen.XMLWriter



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