Kenji, 

Following on Thomas's comment, yes, you can use the setSVGCanvasSize
method
on SVGGraphics2D and the rasterizer will use it. However, this will only
set the width and height attributes. If you'd like to set the viewBox
and preserveAspectRatio attributes, you'll have to get the <svg> root
from SVGGraphics2D (getRoot()), and set these attributes yourself,
something like:

...
Dimension canvasSize = ...;

Element root = svgg2d.getRoot();
root.setAttribute("preserveAspectRatio", "xMinYMax slice");
root.setAttribute("viewBox", "0 0 " + canvasSize.width + " " +
canvasSize.height);
....

Cheers,
Vincent.
> Hi,
> 
> I'm writing SVG-->Raster images converter servlet and encountered a problem.
> What I want to do is to take a snapshot of a Swing application JInternalFrame, 
>highlight some portion of the diagram by modifying SVG through DOM,
> and convert it to raster images such as PNG or JPEG to show users whose browser 
>doesn't have SVG plugin.
> 
> First I take a screenshot and supposed the size is 800x600 pixels. The output raster 
>image size is 400x400 and the contents is clipped to the size.
> I supposed giving KEY_WIDTH=800 and or KEY_HEIGHT=600 would change the clipping size 
>as well as the output image file size, but what happened with these parameters was
> getting the image clipped by 400x400 enlarged to 800x600 size.
> I know the 400x400 value is defined at getViewportSize() in ImageTranscoderUserAgent 
>internal class, but it seems no way to change it from external.
> 
> What I expect is to get the raster image with the same size of the JInternalFrame 
>component. Here "the same size" means same as clipPath info in the SVG. 
>     <defs id="defs1">
>       <clipPath clipPathUnits="userSpaceOnUse" id="clipPath1">
>         <path d="M0 0 L675 0 L675 554 L0 554 L0 0 Z" />
>       </clipPath>
> 
> It would be best if transcoder recognizes clipPath info in SVG, but it is okay to 
>specify these values explicitly.
> 
> Do I overlook something?
> 
> My environment is as following;
> -Batik1.1.1
> -JDK1.3.1
> -Servlet container: Weblogic6.1 SP1
> 
> Thanks in advance,
> ----
> Kenji Nakamura

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

Reply via email to