You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Stephane Hillion <St...@sophia.inria.fr> on 2000/12/19 19:26:08 UTC
Re: How to use an already existing DOM Document for generating Images.
Davanum Srinivas wrote:
> Am trying to use the Transcoder to generate a JPG (In Cocoon2). My problem is according to the
> javadocs the first param in transcodeToStream can be a org.w3c.dom.Document, But trasncodeToStream
> throws an Class Cast Exception as it is trying to cast it to a SVGDocument. Now the question is
> what is the "correct" way to pass my own org.w3c.dom.Document to the Transcoder???
>
> TranscoderFactory factory =
> ConcreteTranscoderFactory.getTranscoderFactoryImplementation();
> Transcoder transcoder = factory.createTranscoder("image/jpg");
> transcoder.transcodeToStream(doc, this.output);
>
The transcoder needs a SVGDocument instance, so you have two solutions:
- you can create and manipulate a SVGDocument while you generate the original document in your
application (before using the transcoder). This should be easy to do if you create your documents in
a 'standard' way, ie:
DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
SVGDocument document = domImpl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg",
null);
// then use the document factory methods.
- else, you can recursively transform the original document into a SVGDocument. Easy too.
--
Stephane.