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 Hervé Girod <he...@club-internet.fr> on 2002/11/30 15:16:00 UTC

Problem when converting WMF files to SVG ?

Hello !

I have a problem when converting WMF files (generated by PPT 2000) to SVG using org.apache.batik.transcoder.wmf.tosvg package (i'm using version 1.5 beta 4b, and the result is the same with the last CVS version of the package classes) : in the resulting SVG file, the bounding box is much more larger than the real bounding box of the initial WMF graphics.

This problem involves the two following classes : WMFPainter & RecordStore. I think it comes from the following :
  a.. the WINDOW_EXT record is much more larger than the real bounding box of the WMF graphics. 
  b.. When WMFPainter encounters this Record, it stores this as vpW and vpH of the RecordStore. 
  c.. These dimensions are used to define the bounding box of the associated SVGDocument. So when this document is rendered (for example via a JSVGCanvas), the bounds are much too large too.
I found a simple solution to fix this (is it all right, or did I completely misunderstood something ?) :
  a.. modify the RecordStore class to add two new attributes vpWext and vpHext (to store external dimensions) and their setters /getters (sepVpWext, setVpHext, getVpWext, getVpHext  ) 
  b.. modify the WMFPainter class : The WINDOW_EXT record no longer modify the bounding box of the RecordStore, but is used to define the scaling.
                case WMFConstants.META_SETWINDOWEXT:
            /* change sepVpW and setVpH by sepVpWext and setVpHext :
             * 
             *   In CurrentStore, two new infos are added: VpWext and VpHext :
             *   the scale is then identical in X and Y coordinates and don't
             *   take into account the External dimension */ 

             currentStore.setVpWext( vpW = mr.ElementAt( 0 ).intValue());
             currentStore.setVpHext( vpH = mr.ElementAt( 1 ).intValue());
             scaleX = (double)w / vpW;
             scaleY = (double)h / vpH;
             scaleX = Math.max(scaleX,scaleY);
             scaleY = scaleX;



Hervé Girod