views:

340

answers:

3

Hi,

Is there a way in Java, to copy the contents of the clipboard (an image in my case) to the end of a word document?

I want to have a program that will - * Take a filename (word file) as a parameter * Whenever this program is run - it will open the word file and paste the contents of the clipboard to the end of the document.

I am done with the first part - but am struggling with the second part. Also tried POI but could not get it to work.

Any help or pointers are greatly appreciated.

Regards, - Ashish

A: 

Haven't tested it, but I would try these steps:

After reading the document, try to read the image from the clipboard (you can have a look at this website: ToClipImg.html) and temporarily (File.createTempFile(...)) save the image to disk. It might be easier to save the image first and then add it with POI.

Hans Doggen
A: 

I don't know which library/code you're using for parsing the Word file, but Aspose.Words does a pretty good job parsing Word files. It's not free however, but it is rather straightforward to use, has decent enough documentation and a pretty solid forum-based helpdesk.

Check out their website. And no, I'm not an Aspose employee, it's just a good piece of software :)

pHk
A: 

http://poi.apache.org/hwpf/index.html

It is in early development but you can check it out in the SVN dir