Hi Dominik,

I wouldn't try to implement it in HWPF (.doc), because it's easier to
implement in XWPF (.docx).

This is how I would approach the problem - I have to admit, I haven't done
it in XWPF yet ...:

First of all, you need to decide, if you want to embed (1) or attach (2) a
document.

(1) ... you would see part of the document in the word page, e.g. part of
the excel sheet
(2) ... you would see a symbol of the document or the package manager

Next thing is to create such a document by hand (in Word).

If a template mechanism is ok, i.e. always the same embedded element(s)
needs to be replaced,
then you can replace the file under /word/embeddings/... in the .docx (which
is a zip-file).
The OPCPackage class is your friend.
Either check the junit/examples classes of POI or google/check other
examples on how to use OPCPackage [a]

Otherwise you need to check the document.xml and reproduce the o:OLEObject
and it surrounding elements by directly accessing the XmlBeans of XWPF
document.
An example on how to access the xmlbeans is [b], of course you need to adapt
it for the o:OLEObject.
As o:OLEObject is in a different namespace, you can't create the necessary
xml nodes via the xml parent (parent.newXYZ..()), but need to create it via
the corresponding document factory and then set it in the parent.

If you need further assistance, best is to start a SSCCE [c] on pastebin or
similar which can be successively enhanced.  

Andi

[a]
http://stackoverflow.com/questions/32561366/add-custom-xml-part-using-apache-poi
[b]
http://stackoverflow.com/questions/33970037/unable-to-change-orientation-of-ms-word-filexwpf-using-apache-poi
[c] http://sscce.org/



--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Embed-files-into-Word-tp5721359p5721360.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to