Hi,

below is a wrapper function for printNode which works on various browsers/SVG UAs: ASV, Batik, Opera, Firefox, Safari, etc.

you can pass a DOM node and get a string containing the XML fragment which you can send to Batik on the server. There is also a tutorial on getURL/postURL/XMLHttpRequest at http://www.carto.net/papers/svg/network_requests/index.shtml

As an alternative to passing the whole document, you could also pass only simple parameters, such as color values, which are read by a serverside script/servlet and fed into Batik and used in an onload script.

============

//this is a wrapper function for the different methods to serialize an XML node to a string
function serializeNode(node) {
 if (typeof XMLSerializer != 'undefined') {
   return new XMLSerializer().serializeToString(node);
 }
 else if (typeof node.xml != 'undefined') {
   return node.xml;
 }
 else if (typeof printNode != 'undefined') {
   return printNode(node);
 }
 else if (typeof Packages != 'undefined') {
   try {
     var stringWriter = new java.io.StringWriter();
Packages.org.apache.batik.dom.util.DOMUtilities.writeNode(node,stringWriter);
     return stringWriter.toString();
   }
   catch (e) {
alert("Sorry, your SVG viewer does not support the printNode/serialize function.");
      return '';
   }
 }
 else {
alert("Sorry, your SVG viewer does not support the printNode/serialize function.");
   return '';
 }
}

==========

Andreas

[EMAIL PROTECTED] wrote:

Hi Harvey,

"Harvey Rayner" <[EMAIL PROTECTED]> wrote on 03/19/2007 10:55:38 AM:

i have svg files that users can modify using a javascript interface.

i want to send these modified svg files to the rasterizer. what would be the best way to do this?

  Construct a batik.transcoder.TranscoderInput from the
modified document (requires a little bit of Java programming),
then pass that to the JPEG/PNGTranscoder class (Assuming
the modifications are done with the JSVGCanvas).

  You could also use batik.dom.util.DOMUtilities to write
the document to disk and then run the rasterizer on that,
but that would be noticably slower.

  If your changes are done in something other than Batik
then you will have to figure out how to write the modified
document out (ASV had a method called printNode).

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: [EMAIL PROTECTED]
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to