Replies: 7   Views: 1500
Problem with inline style
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  · 20-07-2020 - 09:13


Running the following code Roboto font is applied to the text contents in the document body correctly (that uses a very similar code than the samples included in the package):

$docxFinal = new CreateDocx();

$docxFinal->importContents('ArticoloClelia.docx', ['type' => 'paragraph']);
$docxFinal->embedFont('fonts/Roboto/roboto.ttf', 'Roboto');
$docxFinal->embedFont('fonts/Roboto/robotoi.ttf', 'Roboto', ['styleEmbeding' => 'Italic']);
$docxFinal->embedFont('fonts/Roboto/robotob.ttf', 'Roboto', ['styleEmbeding' => 'Bold']);
$docxFinal->embedFont('fonts/Roboto/robotobi.ttf', 'Roboto', ['styleEmbeding' => 'BoldItalic']);

$defaultStyle = [
    'font' => 'Roboto',

foreach (array('paragraph', 'run', 'list', 'style') as $type) {
        $docxFinal->customizeWordContent(['target' => 'document', 'type' => $type], ['font' => 'Roboto']);


We have checked the output with MS Word 2007, MS Word 2010, MS Word 2013, MS Word 2016, MS Word 2019, LibreOffice 5 and LibreOffice 6 and in all cases Roboto is applied to all existing contents in the document body content.

Also please note that your code has some errors, for example:

  • 'attributes' => ['w:*'

w:* is not a valid attribute, you need to set a specific attribute name, not a wildcard, to get the correct attribute to be changed.

  • [ 'type' => 'style', 'target' => 'style', 'customAttribute' => '//w:body/w:r[1=1 and descendant::w:rFonts[contains(@w:ascii, "*")]]' ]

you are trying to change the style target (style file) with the customAttribute //w:body/w:r that is a tag (not an attribute) that only exists in the document.xml file.

Also please note that your DOCX contains footnotes that aren't supported in the current version of DOCXCustomizer (

target  string  document (default), style, lastSection, header, footer.