Replies: 9   Views: 5049
List & table fonts change after merging
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 Nucleus  · 19-03-2016 - 13:45

I'm generating a document with all text being Arial which is also set as default font. This document includes images, tables, lists, headings and normal text. This works perfectly fine.

Now the issue comes when trying to add, or merge with, another document. I have tried both the "addExternalFile" when creating the document and also saving in a temporary location to then use "mergeDocx" to combine both.

After either of those actions the font in the lists and tables change (I've seen both Raleway Regular and Calibri, neither are used anywhere in both documents). Also all lists suddenly become ordered/numbered lists and even when trying to apply custom styling theres no way to get bullet points.

Basically before merge all fonts are Arial and lists have bullet points. After merge the font in tables and lists change and all lists become numbered.

I've tried pretty much any combination of parameters and options for hours now but nothing seems to work.


Any help or information would be greatly appreciated.

Posted by admin  · 19-03-2016 - 20:02


The recommended method to merge docx is the MultiMerge class:

The addExternalMethod uses altChunk tags and doesn't preserve most of the styles of the document.

Please try this code:

require_once 'classes/';
$merge = new MultiMerge();
        'mergeType' => 0,
        'numbering' => 'restart',
        'forceLatestStyles' => true,

If you still have issues please send to contact[at] the documents you're trying to merge to check them.


Posted by therasim  · 18-05-2016 - 02:56

I'm using 5.5 version and even using the configuration you describe I see that issue as well. Any advice?

Posted by admin  · 18-05-2016 - 09:04


The problem of the documents of this user was that both DOCX had a default font, so the final document used the first default font for the whole document (a DOCX can't have more than one default font).
To solve this issue, instead of using:


you need to set the font family for each content, for example:
$docx->addText("Lorem ipsum", array('font' => 'Roboto'));


After doing this change all fonts merge fine.

Posted by therasim  · 18-05-2016 - 10:50

Will that solve as well the bulleted lists now turning into numbered lists inside tables?

Posted by admin  · 18-05-2016 - 11:28


We wasn't able to replicate the issue with the user's documents, but you can import the missing styles of the lists after the merging.


Posted by therasim  · 18-05-2016 - 18:20

How can I achieve that once it's merged? I haven't found any examples on how to do that

Posted by admin  · 19-05-2016 - 06:27


You need to use the importStyles method or add them in the first merge DOCX. This API method is explained on the API documentation pages and it includes examples.

We also recommend you to download the new version of the MultiMerge class that will be available in the next release of phpdocx and include new improvements.


Posted by NicolaiW  · 20-05-2016 - 07:42


I have the same issue - almost anyway - mine happends right after a table.

In my case it happends in a template on one line only - so I have lines that work fine and doesn't get new font type - both after and before, where I use a combination of text from the template and replaceVariableByText. 

I replace many variables in the template and your examples does not cover this and I don't want to define a font type for each context - that would be crazy.

Have downloaded latest version of

Sure I can probably find a workaround and will have to - since none of the solutions suggested works for me, but you have to look into this as an error - because that is what it is.

EDIT: Now I have done a bit more investigation and it seems a lot like the error is related to replaceVariableByText for me. The method replaceTableVariable is for example not getting overwritten on merging in any cases

Posted by admin  · 20-05-2016 - 13:40

Hello NicolaiW,

We think your issue is distinct than the other user. Please send to contact[at] the smallest script (this is without doing external connections such as databases or web services) that illustrates your issue and we'll check it. Please also attach the templates used by your script.