Forum


Replies: 2   Views: 3234
Embedded html : how to inherit the font size and family of a template document?
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 Bouillou  · 01-11-2017 - 20:01

Thank you for your reply.

By removing font-style and font-family, then wrapping a div with font-size:initial, the embeded HTML is formatted as the "Normal" sytle is defined in the template. It is enough for me, I can customize each template as I want with the "Normal" style and a generic PHP code. 

In case of more than one style is needed, check replaceVariablebyHTML methods strictWordStyles and wordStyles.

//Convert accents in html entities
$html = htmlspecialchars_decode(htmlentities($html, ENT_NOQUOTES, 'UTF-8'), ENT_NOQUOTES);

// Remove font-size CSS statements
$html = preg_replace("/font-size: ?(\d*[.])?\d+(px|%|pt);/", '', $html);

// Remove font-family CSS statements
$html = preg_replace("/(font-family:)(.+?)(;)/", '', $html);

//Set the font size
$html = "<div style='font-size:initial;'>".$html."</div>";

Best regards