Hi,

I created an application which allows a user to capture screenshots and save them as images at a pre-defined location. Now, I want to insert the saved images to a word document.

I am aware of Apache POI, but that is still under development and it seems that you can only read documents with POI and not write.

Can anyone please suggest how I can solve this problem. Please don't reccomend any open source tools.

Thanks,
Anuj Sharma

I tried the following:

document.createParagraph().createRun().addPicture(new FileInputStream(saveLocation),document.PICTURE_TYPE_JPEG,imageName, 328, 247);
try 
{
    document.write(outStream);
    outStream.close();
} 
catch (FileNotFoundException e) 
{
    e.printStackTrace();
} 
catch (IOException e) 
{
    e.printStackTrace();
}

I can see the document file size increase, however when I open the document it is asking me to "Select the encoding that makes your document readable".

Anu suggestions.

The method addPictureData only add the picture data in the word document, thats why we can see the document size increase.

However it does not show the picture becuase POI doesn't support it. iText is a better alternative.

This question has already been answered. Start a new discussion instead.