Replies: 3   Views: 464
Docx variable using replacevariablebywordfragment
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  · 07-05-2022 - 19:11


When a placeholder is replaced by a WordFragment, the tag container of the placeholder is replaced, including the inline styles of the tag. If the styles are applied to the parent element of the element (for example paragraph styles when doing an inline type replacement) then these styles of the parent remain. This doesn't happen when only the text is replaced as using replaceVariableByText (and other replace methods),

Using a Basic or an Advanced license you need to set the styles to be applied in the new content created with the WordFragment.

Premium licenses include the stylesReplacementType option in the replaceVariableByWordFragment method to apply the placeholder styles or mix the styles from the new content and the styles from the placeholder when doing the replacement.