Page 1 of 1

Need support to handle EMF,WMF images :

PostPosted: Fri Jan 29, 2010 2:01 am
by AnbuChezhian
Hi ,

I am converting a docx containing image ( wmf ,emf ) into html .
But i could not find any image in html. It seems docx4j does not
support wmf and emf image files.

Please suggest some third parties to handle these images .

Thanks in advance,
Anbu.S

Re: Need support to handle EMF,WMF images :

PostPosted: Fri Jan 29, 2010 10:40 pm
by jason
I haven't looked at this in depth, but a quick Google yields various options including:

1. Your easiest option might be ImageMagick; that can (or used to be able to) convert from wmf. docx4j already uses IM to go the other way, that is, to convert image formats which aren't supported by Word into ones which are. See the Getting Started guide, or BinaryPartAbstractImage

2. You could also try http://code.google.com/p/wmf2svg/ which is Java / Apache 2 licenced code.

3. Batik can also convert wmf to svg

4. iText also has WMF support (might use batik?)

Please report back on your findings!

cheers .. Jason

Re: Need support to handle EMF,WMF images :

PostPosted: Sat Jan 30, 2010 1:43 am
by AnbuChezhian
Hi Jason ,

Thanks for your response .
Please try out this jar
http://epub-tools.googlecode.com/files/ ... -0.3.0.jar .
They are handling both wmf and emf files.
But still facing some problem in emf conversion.

Can u suggest some third party jar to handle emf to svg conversion ? .

Regards,
Anbu Chezhian.S

Re: Need support to handle EMF,WMF images :

PostPosted: Sat Jan 30, 2010 9:10 am
by jason
Hi Anbu Chezhian.S

Thanks very much for that link! Their parser at [1] may be as good as any a starting point - the bug you mention may be easily fixed.

Ideally, what we need is a range of documents to try converting with each of the above tools, so we can understand their relative strengths.

It would be nice if docx4j could convert EMF/WMF to say, SVG, for the purposes of pdf and html output.

If you are able to share a range of test EMF and WMF files, and your thoughts on the available options, we can look at adding support.

cheers .. Jason

[1] http://code.google.com/p/epub-tools/sou ... arser.java

Re: Need support to handle EMF,WMF images :

PostPosted: Mon Feb 22, 2010 10:14 pm
by jason
I've now spent some time investigating various options for converting EMF and WMF files to SVG and/or PNG.

The options I looked at were the ones listed earlier in this thread, plus 2 others:

- com.adobe.dp.office
- wmf2svg
- batik
- freehep
- imagemagick
- openoffice

I tried them using EMF and WMF files created by saving shapes from Powerpoint 2007 (either Save as Picture .. on the object itself, or Save As .. for the document, then saying just the slide)

My conclusion is that there is no simple solution. It would be nice to be able to use com.adobe.dp.office, since it has both EMF and WMF parsers, but its EMF parser needs a lot of work.

wmf2tosvg is a good solution for WMF, but it has no EMF support. For WMF, I'm inclined to use wmf2tosvg. This can be revisited if/when com.adobe.dp.office improves.

What to do about EMF?

FreeHEP has EMF2SVG, but the output wasn't much good (perhaps because office drawings aren't its primary focus). It would also be a very complex dependency.

Batik has WMFTranscoder, but not EMFTranscoder! It looks like one could be added from package org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg.metafile with a bit of work, but still, batik is no good on appengine since it uses awt, and spawns threads. So avoid it..

imagemagick does a nice job with WMF, but has no support for EMF at all (other than on Windows).

openoffice can be used to convert EMF and WMF; I found it worked well. Until the EMFParser in com.adobe.dp.office is fixed, this may be a good option (depending on your environment). Maybe the code to use openoffice for EMF conversions could go in src/docx4j-extras, so only those who wanted to use it would need to worry about the dependencies.

I'll explore using svgsalamander for PNG output (as an alternative to Batik) - though this too requires AWT :-(

Re: Need support to handle EMF,WMF images :

PostPosted: Tue Feb 23, 2010 5:35 pm
by jason
Support for WMF (but not EMF) in HTML output was added
in http://dev.plutext.org/trac/docx4j/changeset/1078

Re: Need support to handle EMF,WMF images :

PostPosted: Wed Mar 03, 2010 10:40 pm
by manikandan
Hi Jason,

Thanks for the details and analysis about the WMF and EMF support.

My 2 cents.

1 Image handling which are present in Header and Footer. Docx4j doesn't support (i have modified WordXmlPicture.java according to this)
2.WMF and EMF Handling. WMF/EMF -> SVG -> PNG/JPG

WMF/EMF->SVG (using com.adobe.dp.office parsers. As u said, it is not supported EMF now).
SVG->PNG/JPG (using batik transcoders)

i here attached the modified code for the same. Have a look at this. If u find it to be useful then use it in docx4j.

Thanks,
Manikandan.S