Categories > OpenTBS with DOCX >

Copy content from one docx into another and keep format.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Valentin
Date: 2015-08-05
Time: 09:05

Copy content from one docx into another and keep format.

I know that there is the possibility of extracting the plain text content of an docx file, but I want to copy the content and keep the format of the text.
The scenario looks like this: I have a couple of docx files with text snippets and then my php script combines them in different possible ways and generates a new docx file.

Thanks for help!
By: Skrol29
Date: 2015-08-05
Time: 14:05

Re: Copy content from one docx into another and keep format.

Hi Valentin,

Despite you can easily read the $TBS->Source property in order to find the proper XML elements for text parts, the combination of text parts coming from separated DOCX won't be a valid content foe a new DOCX.
This is because the text part may have some ids that are references to other part of the DOCX such as formating, comments, pictures, charts, footer, ... and such ids are not valid in the new DOCX.

The combination of two DOCX seems to be for now only possible within Ms Word, unless you can manage and drive the inner formating ids.