Problem:
I have an image of an extended Extat Plus EMF + metafile extension . I need to convert this file to a PNG image file using java.
Attempts to solve the problem in java:
Apache Batikdoes not support EMF + format (Batik only supports WMF format ).
FreeHEPdoes not support EMF + . It can convert EMF to SVG and then SVG to PNG . I was hoping this would help:
EMF2SVG.main( new String[] {inputMetaFileName,ontputSvgFileName});
this statement should convert EMF to SVG , but gives an exception:
java.lang. exportchooser.AbstractExportFileType.exportToFile (AbstractExportFileType.java:282) at org.freehep.graphicsio.emf.EMFConverter.export (EMFConverter.java:81) at org.freehep.graphicsio.emf.EMF2SVG.main (EMF2VV)
I used the code here :
try {
EMFRenderer emfRenderer = new EMFRenderer( new EMFInputStream(
new ByteArrayInputStream(emfBytes)));
EMFPanel emfPanel = new EMFPanel();
emfPanel.setRenderer(emfRenderer);
FileOutputStream svg = new FileOutputStream("svg.svg");
SVGGraphics2D graphics2D = new SVGGraphics2D (svg, emfPanel);
graphics2D.startExport();
emfPanel.print(graphics2D);
graphics2D.endExport();
svg.flush();
svg.close();
} catch (IOException e) {
e.printStackTrace();
}
This code creates an SVG file , but the file has no image.
source
share