File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes inserting image into a MS-WORD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "inserting image into a MS-WORD" Watch "inserting image into a MS-WORD" New topic

inserting image into a MS-WORD

rajkumar sound

Joined: Aug 29, 2008
Posts: 11
i have generated MSWORD(.doc) document from my JSP page. I want to know how i can insert an image from my desktop to that document.
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3274

Hi there,

I assume you are using apache POI to create the word doc?

In that case you should be able to perform a file upload from your JSP/servlet app (there are 1000's of examples on file upload out there on the web, just search for "jsp file upload example") and insert the image using the API (I'm going to blindly assume that the API supports this).

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41599
I'm going to blindly assume that the API supports this.

I don't believe so. POI can extract images from a DOC file, but to my knowledge not insert images. POI's features regarding creating and changing DOC files (as opposed to reading them) are rather limited.

Ping & DNS - my free Android networking tools app
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3274

Hi Ulf, thanks for the clarification, I should be a little less lazy and check these things . <scurries off>, right I've actually looked at their site and API and I can see that it supports embedding png files into Excel spreadsheets but indeed doesn't appear to support inserting images into Word docs (in fact there is a TODO on their web site for better support around this area).

Disclaimer: I'm not a user of the POI libraries
I agree. Here's the link:
subject: inserting image into a MS-WORD