Forum


Replies: 4   Views: 3579
Replacevariablebyexternalfile changes border and background colors of tables
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Philippe GAUTHIER  · 29-08-2016 - 14:00

Hello,

I am integrating a Word docx file into another using replaceVariableByExternalFile. The first one contains tables having different background colors (blue, green and orange). The second one contains just the template var replaced by the first document.

As a result, the tables border and background colors are all messed up (changed to respectively a kind of light blue, dark grey and green, borders and background alike).

Thx for your answers.

 

Posted by admin  · 29-08-2016 - 16:42

Hello,

The methods addExternalFile and replaceVariableByExternalFile use altChunk tags. This is a 'special' tag supported only in MS Word 2007 for Windows and newer that allows to embed DOCX, MHT, HTML...

As you can read on their API pages, these methods have some limitations (we can't control it behaviour and it's not supported by the conversion plugin). The option matchSource, available for both methods, request Word to preserve the styles as much as possible, so we recommend you to try it.

Anyway, we recommend you to use ther mergeDocx method to merge DOCX documents (http://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP) and the template methods to use a more avanced approach that allows to keep all styles and it's compatible with the conversion plugin and any DOCX reader.

Regards.

Posted by Philippe GAUTHIER  · 31-08-2016 - 09:39

Hello,

I've tryed changing the option matchSource, but it does not change the result.

We are however bound to the use of template vars to compose documents. Is there a way to split a Word document in two at any $VAR$ location, so we can merge them afterwards ?

Posted by admin  · 31-08-2016 - 13:38

Hello,

There's no method to split a document; we have added it to the list of tasks to consider adding it. We recommend you to work with separate templates (or documents from scratch) and merge them.

Regards.

Posted by Philippe GAUTHIER  · 02-09-2016 - 15:35

Thx for your time. After some digging, the color switching was due to different themes configuration in Word. This method therefore preserves color indexes, but will not preserve the theme colors.