wood burning stoves 2.0*
The moose likes Java in General and the fly likes Graphics and word documents Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Graphics and word documents" Watch "Graphics and word documents" New topic
Author

Graphics and word documents

Michael Helgens
Greenhorn

Joined: Jun 18, 2009
Posts: 1
Right,

So I've got this stack of code that sorts through a text file and writes all of the things neatly just how I want them into a word document for printing. The only trouble is that I would like to include an image at the top of the word document which I have stored in a .png or .jpg file as needed. Is there a way to get Java to put the image(s) at the top of the page before writing the rest of the document?

Thanks, in advance, for your help,

-M
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Had you tried taking the image as a bit stream and writing at the start of word document ?


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
Welcome to JavaRanch.

Word documents are structured file formats; simply prepending binary image data to them is not going to work.

The common Java API for working with DOC files is Apache POI, and it doesn't yet support adding images (although it can extract existing images just fine). A workaround (or hack, depending on your point of view) is described here. In particular, in the messages by Rainer Schwarze of Oct 11 and Oct 15.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Graphics and word documents
 
Similar Threads
How to write the content from document file to jsp page
how to retrieve image from database?
Image not dispaying in RTF document (Worddocument) using iText API
problems in showing images in jsp with contentType= application /msword
MS-word document file to XML in Java