Forum


Replies: 3   Views: 1304
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 geofhoch  · 12-05-2021 - 14:36

Hi,

I used "createDocxFromTemplate" to load my template document.

I would like to know if it's normal that the font size of my title are changing after "createDocx" function ?
They changed from 11 to 12 for no reason.

Can you explain please ?

I can give you the template i use and the result of the script.

Thank you.

Posted by admin  · 12-05-2021 - 15:03

Hello,

phpdocx (using CreateDocxFromTemplate, CreateDocx or other class) doesn't change any content or style unless some method is called to change them. Please send to contact[at]phpdocx.com the most simple script (using phpdocx standalone) that illustrates your issue, the DOCX you are using as template and the DOCX output you get, so we can check them.

Regards.

Posted by geofhoch  · 17-05-2021 - 13:51

Hello,

Thank you.

I sent you en email with my script, the templates and the result.

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.