Forum


Replies: 2   Views: 3723
Replacevariablebyhtml doesn't use $variable$ font & fontsize
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 smartbit  · 29-04-2015 - 10:08

I have a template docx with some variables and one variable is being replaced with a html table using the replaceVariableByHTML function. This works but the font & fontsize from my templates variable (Verdana, 10pt) is replaced with Cambria 12pt. With replaceVariableByText everything is correct. Is there a way to read out the markup from the variable so I can set it with

Posted by smartbit  · 29-04-2015 - 10:28

also tried replaceVariableByWordFragment with the same result, font Verdana, 10pt is replaced with Cambria, 12pt. $valuesTable = array( array(11, 12, 13, 14), array(21, 22, 23, 24), array(31, 32, 33, 34), ); $paramsTable = array( 'border' => 'single', 'borderWidth' => 10, 'borderColor' => 'B70000', ); $table = new \Phpdocx\Elements\WordFragment($docx); $table->addTable($valuesTable, $paramsTable); $docx->replaceVariableByWordFragment(['codestabel' => $table], ['type' => 'block']);

Posted by admin  · 29-04-2015 - 15:16

Hello, The easiest solution to keep the styles of a text in a template when replacing a placeholder with replaceVariableByHTML and replaceVariableByWordFragment is to create a custom style. Please read this page for more information: https://support.office.com/en-nz/article/Style-basics-in-Word-d382f84d-5c38-4444-98a5-9cbb6ede1ba4 Regards.