Page 1 of 1

EPS in Word

PostPosted: Thu Aug 05, 2010 4:45 am
by claudioiac
Ciao Jason,
I was trying to insert an EPS file in Word in the same way how I do for a PNG or an EMF:

BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordprocessingMLPackage, bytes);

where bytes is the image as an array of bytes.

Somehow if the file is an EPS I receive the exception:
BinaryPartAbstractImage The file format is not supported. No ImagePreloader found

In Word you don't have any problem to insert an eps so I don't see where should be the problem with docx4j.

Thank you in advance
Regards

Claudio

Re: EPS in WORD

PostPosted: Thu Aug 05, 2010 9:10 pm
by jason
[CORRECTED 7 Sept 2010]

docx4j needs to know the dimensions of the image. To ascertain this, it currently uses org.apache.xmlgraphics.image.loader.ImageInfo, which can in fact provide the necessary info for an EPS file. (In this respect, its better than Sanselan, which can't)

So far, so good.

The problem is that Word doesn't actually embed an EPS directly. Instead, it converts it to an EMF. (See http://atastypixel.com/blog/inserting-v ... documents/ regarding use of pstoedit to do this)

At present, docx4j doesn't attempt to do this.

Instead, it uses imagemagick (be sure to name it imconvert), to convert the EPS to PNG, which can of course be inserted without EMF.

Re: EPS in WORD

PostPosted: Tue Sep 07, 2010 12:31 am
by twendlan
Hello,

first of all thanks for docx4j :-)

For my current project, I need to add eps files to my docx document. Is there another option than installing imagemagick (this is not possible in our environment) to insert an eps file?

Cheers
Tino

Re: EPS in WORD

PostPosted: Tue Sep 07, 2010 5:02 pm
by jason
Hi Tino

I've revised my answer above, and deleted our exchange of yesterday, since it was based on incorrect info.

I'll have another look at the EMF stuff over the next few days.

If you can find an open source pure Java approach for converting EPS to say, PNG, please let me know. (There are several online tools for doing this, btw, though obviously not the best solution)

cheers .. Jason