poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Burch <nick.bu...@alfresco.com>
Subject Re: Unicode Byte terminator for PicturesTable and HWPFDocument.
Date Wed, 22 Sep 2010 13:26:45 GMT
On Wed, 22 Sep 2010, Zachary Mitchell wrote:
> "Word picture structures are concatenated one after the other in the 
> data stream if the document contains pictures. Data stream is easily 
> reachable via HWPFDocument._dataStream property. A picture is 
> represented in the document text stream as a special character, an 
> Unicode  whose CharacterRun.isSpecial() returns true. The file location 
> of the picture in the Word binary file is accessed via 
> CharacterRun.getPicOffset(). The CharacterRun.getPicOffset() is a byte 
> offset into the data stream. Beginning at the position recorded in 
> picOffset, a header data structure, will be stored. "

Take a look at HWPF Picture and PicturesTable to see the read side of this 
largely implemented

> If I wish to insert one or more Picture(s), 
> [org.apache.poi.pwpf.usermodel.Picture] picture files, from a 
> Java.io.File object of an available OS file,

You'll hit a snag here. The Picture object, as mentioned in the docs you 
cite, is both a bunch of header fields as well as the raw bytes of the 
image itself. You'll need to create the appropriate headers, and currently 
HWPF doesn't support this. HWPF doesn't even fully support decoding the 

If you only want to support PNG and JPG, it might not be too bad, as they 
appear to have fairly simple headers. BMP, EMF and WMF are all a lot more 
complicated from what I can tell

Finally, you have to add a single character character run into the right 
place in the document (or two, if you're doing floating pictures), and set 
the appropriate properties. This is probably supported at the low level, 
but there's no high level way on a CharacterRun to do this

If you do have some luck with decoding and/or creating the picture 
headers, please send in patches!


To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

View raw message