xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject RE: CSS ignored when exporting to JPG
Date Tue, 11 Apr 2006 13:12:46 GMT
Hi Dylan,

"Dylan Browne" <dbrowne@mango-solutions.com> wrote on 04/11/2006 07:12:20 
AM:

> So Im guessing the stylesheet is not being found now?
> org.w3c.dom.DOMException: Null Document reference: Invalid CSS document.

   Correct, most likely Batik can't find your CSS style sheet.  Commonly
this is cause by using a relative reference when a Document without a 
knowable base url is used.  In this case the problem is that you haven't
properly set the xlink:href attribute:


>         css.setAttributeNS(null, "xlink:href",
> "http://localhost:7001/SVGWeb/style.css");

    This needs to be:
        String XLINK_NAMESPACE_URI = "http://www.w3.org/1999/xlink";
        css.setAttributeNS(XLINK_NAMESPACE_URI , "xlink:href",
 "http://localhost:7001/SVGWeb/style.css");

    Assuming you have an HTTP server on local host at port 7001
with a document at that location...


> -----Original Message-----
> From: Dylan Browne [mailto:dbrowne@mango-solutions.com] 
> Sent: 11 April 2006 11:13
> To: batik-users@xmlgraphics.apache.org
> Subject: CSS ignored when exporting to JPG
> 
> Hi,
> 
> I have a problem when attempting to rasterize an SVG document created 
using
> the Batik DOM classes. It looks like the rasterize process is not 
picking up
> the stylesheet I am importing.
> 
> I include my stylesheet like this (this works fine in so far as 
rendering
> SVG in the browser goes):
> 
>         ProcessingInstruction pi = null;
>         // import the stylesheet
>         pi = doc.createProcessingInstruction("xml-stylesheet", 
Config.CSS);
>         doc.insertBefore(pi, doc.getDocumentElement());
> 
> When I am creating my JPG, I use the following code. This does generate 
the
> jpg, but any elements which are styled are not picked up so I end up 
with a
> largely black image with a few shapes visible:
> 
>     public void streamSVGIntoImageFormat(SVGDocument doc) {
>         try {
>             // create a JPEG transcoder
>             JPEGTranscoder t = new JPEGTranscoder();
>             // set the transcoding hints
>             t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new 
Float(.8));
>             // create the transcoder input
>             TranscoderInput input = new TranscoderInput(doc);
>             // create the transcoder output
>             OutputStream ostream = new FileOutputStream("c:\\out.jpg");
>             TranscoderOutput output = new TranscoderOutput(ostream);
>             // save the image
>             t.transcode(input, output);
>             // flush and close the stream then exit
>             ostream.flush();
>             ostream.close();
>         } catch (Exception e) {
>            e.printStackTrace();
>         }
>     }
> 
> Does this look like an issue with how I import my stylesheet, or an 
issue
> with how I am calling the Transcoder code?
> 
> Thanks in advance for any help,
> 
> Kind regards,
> 
> Dylan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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


Mime
View raw message