Forum


Replies: 3   Views: 3777
Trying to use custom paragraph styles as headings included in table of contents
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  · 19-01-2016 - 09:01

Hello,

We recommend you to use the fontSize option when you add the text or duplicate the value of sz. This is:

$style1 = array('outlineLvl' => 1,
                    'jc' => 'left', 
                    'spacingBottom' => 100, 
                    'font' => 'Times New Roman', 
                    'bold' => true, 
                    'sz' => 32,
                    'color' => ORANGE);

or

$docx->addText('First Heading1', array('pStyle' => 'style1', 'fontSize' => '16'));

About displayLeves, please use 1-3 to show them:

$tocOptions = array('autoUpdate' => false, 'displayLevels' => '1-3');

Some default Word styles may be showing and they need to be set in this way.

About this chunk of code:

$text =  'This is the first paragraph.';
$docx->addText($text, $pLeft);

the $pLeft variable isn't declared.

Regards.