Replies: 4   Views: 3450
Font size ignored ?
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 Simco Nederland  · 08-01-2018 - 09:41

             $numbering = new \Phpdocx\Elements\WordFragment($docx, 'defaultHeader');
                $numberoptions = array(
                        'textAlign' => 'right',
                'bold' => true,
                'fontSize' => 9,
                'color' => '000000',
                'default' => 1
                $numbering->addPageNumber('page-of', $numberoptions);
                $tableData = new \Phpdocx\Elements\WordFragment($docx, 'defaultHeader');
                $values = array(
                                array('value'=>$partialHeaderData1, 'width'=>3000), 
                                array('value'=>$partialHeaderData2, 'width'=>2000, 'float' => array('align' => 'right'))
                $options = array(
                'border' => 'none',
                'tableAlign' => 'left',
                'borderWidth' => 0,
                'columnWidths' => array(3000, 2000),
                'bold' => true,
                $tableData->addTable($values, $options);

have this code.
partialHeaderData1 is WordFragment with embedded html.
partialHeaderData2 is WordFragment with embedded html to which we add pagenumbering with addWordML

but no matter which font i set to pagenumbering it still shows it as 10pt in word.. tried even to set font size in code to 29 it still shows that at 10pt.


Posted by admin  · 08-01-2018 - 11:17


The styles of page-of must be applied using a paragraph style and the pStyle option. You can use the paragraph styles from a template, imported from an external DOCX or created dynamically (

On the API page of the method ( you can read about the options for numerical, alphabetical and page-of types (options for page-of type).

We also recommend you to check the included sample Core/addPageNumber/sample_2.php that illustrates how to set a custom style to page-of type using the addPageNumber method.


Posted by WTO  · 12-02-2018 - 14:50

I just downloaded the latest 7.5 (licensed, advanced, so not a trial version), and the font size doesn't work. In fact, the official documentation example shown here: doesn't work. The font size is set to 26, but the screenshot clearly shows a much smaller font. 

Executing the example found at examples/LayoutAndGeneral/createParagraphStyle/sample_2.php doesn't work either. The font will always remain at the default size.

Posted by admin  · 12-02-2018 - 17:00


All samples are fully tested. In the sample you point out ( , example #2), the fontSize option is set to 26, that is the equivalent to 13 (MS Word font size units: value / 2) as you can see in the screenshot of the example.

We have run it setting others fontSize values to the paragraph style and the output is the expected (we have opened the DOCX with MS Word 2007, MS Word 2013, MS Word 2016, LibreOffice 5 and LibreOffice 6).

What program and version are you using to open the DOCX?


Posted by WTO  · 13-02-2018 - 09:24

Ok, fair enough. I suggest you put a warning about that in the doc, as it's not immediately obvious that it will be half of what you define. Furthermore, if I put the font-size explicitly when adding something, like so:

$docx->addHeading('My heading', 1, array(
  'fontSize' => 26,
$docx->addText($text, array('pStyle' => 'myStyle', 'fontSize' => 32));

It doesn't divide it by 2; the font size is 26 for the heading, and 32 for the text, and not 13 and 16. So it's not very intuitive.