Forum


Replies: 3   Views: 1270
Font size 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 admin  · 17-05-2021 - 14:25

Hello,

Although we have replied by email, we write here the same content for general information:

Thanks for sending the documents that illustrate your issue. We have checked your DOCX and the font size is changed when merging, not in CreateDocxFromTemplate, in the final DOCX because in the first DOCX the same style name (Normal and also the default paragraph style) has that size. We recommend you to read the information available on https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP to understand how merging styles work.

If you open document1.docx and document2.docx with MS Word and copy/paste that content (Matériel conçu, fabriqué et assemblé en France) from document2.docx to document1.docx, you'll get the same output; this is the title with a 12pt as font size.

In short, although it's explained in deep in the previous link (https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP), phpdocx merges the documents using the same approach as MS Word. By default the first DOCX to be merged sets the base styles to be applied, and only styles with names that don't already exist in the previous documents to be merged are added to the merged output. This workflow is very important to keep the same behaviour as MS Word and also allows doing other important workflows such as continuous numberings when merging documents.

If you want to keep the exact sizes in the documents to be merged overwriting the default phpdocx behaviour (and also the MS Word behaviour that is the same) you need to set a custom style name not used in the previous documents to be merged or use inline styles. Or use the renameStyles option available in mergeDocx.

Regards.