Insert Files as Objects in Exported Word Document with OpenTBS

371 Views Asked by At

I am using OpenTBS to load a word template and complete all the required fields with the information I have.

The problem is that I have some related documents (other words, excels, pdfs) for the exported word, that I have to insert as objects in a specific area. I managed to insert images using MergeBlock and all the other elements I needed.

I need the uploaded files to be inserted in the exported word like an object (not link), just to click the icon and open the related document. I can't find a solution on how to accomplish this and I have no idea how to do this.

Has anyone done this? Is there a solution for my problem? (it doesn't have to be an OpenTBS solution)

1

There are 1 best solutions below

0
On

A DOCX document stores the inserted files into a binary sub-file in the DOCX archive (a DOCX is a zip archives with special sub-files). The binary sub-file is named like word/embeddings/oleObject1.bin and is made with a binary heady followed by the binary content of the inserted file. Such binary sub-file is linked to the body part of the DOCX with an XML element <o:OLEObject> using the "ri:id" attribute and a sub-file named word/_rels/document.xml.rel.

Because of the binary header of the binary sub-file, is is not easy to change the binary content of a existing inserted file. Is is not easy also to create a new inserted file.

OpenTBS gives no special help for this problem. Since you know how to manage the binary header, you can use OpenTBS features to chnage the content of any sub-file, therefore you can edit the existing inserted file.