File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 42371
    
  64
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
 
 
subject: Graphics and word documents