Categories > OpenTBS with DOCX >

multiple documents word file

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: elena
Date: 2013-05-30
Time: 17:01

multiple documents word file

Hello,
i've used opentbs for some months  to produce word documents and I am very satisfied with the result.
I now have the need to  queue  multiple documents of the same type in a single word file : in this way by opening a single file I can print all the documents at once.
For simple cases I solved by inserting the single template inside a word  table cell and exploiting the characteristics of opentbs blocks, but now I should do that appending single documents each consisting of few  pages and this solution doesn't seem very effective: for example, I can't  print the page number and the footer, because any cell that contains the single document encroaches on multiple pages. May you suggest a better solution?
Thanks a lot!
Elena
By: Skrol29
Date: 2013-05-31
Time: 02:46

Re: multiple documents word file

Hi Elena,

I'm surprised your solution worked a bit.
It is quite difficult to combine several Docx in a single one because styles, images  and other peripheral complements are not the same between documents.

Nevertheless, you can try a solution (never tested yet):
In each documents to insert, get the XML part that is between tags <w:body> and </w:body>.
Concatenate all those XML into a single one.
Then, in the single target document,  replace the content that is between <w:body> and </w:body> with the concatenated XML.
By: elena
Date: 2013-05-31
Time: 18:01

Re: multiple documents word file

Hi,

interesting suggestion! I tried it and it works, but for header and footer, that I loose.

what I've done is:
create file 1, dinamically, with opentbs
create file 2 and file 3 in the same way.
The three files have the same template, containing header and footer correctly managed.

I extract xml part from file 1 ,  concatenate it with xml part of file 2 and replace xml part of file 3 with the resulting concatenation.

When opening file 3 Words raises an error message, that I can bypass, but the file, which is correctly formatted, lost header and footer...

Any idea on what's the matter with it?

Thankyou anyway for you attention!
By: Skrol29
Date: 2013-06-01
Time: 00:38

Re: multiple documents word file

Hi,

This is strange because DOCX saves headers and footers in a separated XLM sub-file than main contents.
So the header and footers should be the same as the hosting DOCX file.

I cannot explain the behavior. But you can send to me your file so I could have a look.