Replies: 3   Views: 556
Get style from a document and set style other
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 phosira  · 02-11-2022 - 09:46

How can i get each sentences style(ex.font,bold,align center,etc) from document a,

and set style document b's each centences?

Posted by admin  · 02-11-2022 - 10:15


You need to use two methods available in Premium licenses:

You can get get word styles using the getWordStyles method. This method returns information that can be iterated to get the needed styles.

New styles can be applied to the same DOCX or another DOCX using DOCXCustomizer.


Posted by phosira  · 02-11-2022 - 10:51

actually i tried use getwordstye and get array but i didnt get how im using it.

can you give me some examples?

what im trying to do is,

getwordcontent from document a, translate it, and create document b with translated text which is same style as document a.

Posted by admin  · 02-11-2022 - 11:35


Please check the samples included in the package. All packages include samples of all methods.

On you can find a detailed custom sample that illustrates how to get the font size. The same iteration can be used to get other styles.

You need to translate the style information from getWordStyles to the options supported in DOCXCustomizer.