Page 1 of 1

EMF in Word

PostPosted: Fri Apr 30, 2010 2:45 am
by claudioiac
Hi Jason,
I would like to kow how I could add an EMF image in my Word document. I saw the example for the binaryImage, of course doesn't work in this case.
I expect it's quite easy to do it as Word support this file. As just to be imported in the document.
Thank you in advance.
Cheers,

Claudio

Re: EMF in Word

PostPosted: Sat May 01, 2010 1:29 am
by jason
Hi Claudio

Are you working with the docx4j source code?

If you are, it looks to me that you could add an EMF image just like any other, provided you first changed MetafileEmfPart so that it extends BinaryPartAbstractImage.

If you aren't working with the docx4j source code, please let me know, and I'll give it a try myself.

In saying this, I'm assuming the EMF can have a vanilla w:p/w:r/w:drawing element pointing to it, just like any other image type.

cheers .. Jason

Re: EMF in Word

PostPosted: Tue May 11, 2010 4:37 pm
by jason

Re: EMF in Word

PostPosted: Sat Jun 26, 2010 2:31 am
by claudioiac
Dear jason,
thanks for your answers. Unfortunatly I hadn't the possibility to work on this thing in the last period and I missed the jar that you put in the repository with this impelementation. I looked in the last one in the repository but I didn't find it.
I am not so expert with docx4j and I didin't undestand how to extend the BinaryPartAbstractImage.
This class accepts an array of bites but I just have a EMF file that is a graphic image.
I tryed to open this file as EMFGraphics2D object of the freehep library but as you say I just need to put wrapped in the w:p/w:r/w:drawing element
Could you post me just a simple example??
Thank you very much in advance
Best regards

Claudio

Re: EMF in Word

PostPosted: Sat Jun 26, 2010 5:56 pm
by jason
Hi Claudio

I implemented it in http://dev.plutext.org/trac/docx4j/changeset/1126

The functionality should be in all later builds, including http://dev.plutext.org/docx4j/docx4j-ni ... 100615.jar

The AddImage example http://dev.plutext.org/trac/docx4j/brow ... Image.java should just work if you use it with an EMF. I tried it with sample-docs/metafile-samples/freehand_picture_saveas.emf

If it doesn't please post the stack trace, or better, send me the EMF in question.

hope this helps .. Jason

Re: EMF in Word

PostPosted: Mon Jun 28, 2010 9:02 pm
by claudioiac
Dear Jason,
thanks a lot.
It's actually working very well!
When are you going to publish a new release with these last features?
Best regards

Claudio

Re: EMF in Word

PostPosted: Fri Jul 09, 2010 5:39 pm
by jason
Hi Claudio

v2.4.0 released today - see the announcement sticky above.

cheers .. Jason