Replies: 3   Views: 1417
Toc update before save?
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 dev@ram  · 19-05-2017 - 13:41

Ok thanks,

I added the following code

$docx->addText('Contents',array('pStyle' => 'Heading1'));
    $docx->addText(' ',array('pStyle' => 'Heading1Line'));
    $legend = array(
        'text' => 'Click here to update the TOC', 
        'color' => 'B70000', 
        'bold' => true, 
        'fontSize' => 12,
    $docx->addTableContents(array('autoUpdate' => true,'displayLevels' => '2-4'),$legend);
    $docx->addBreak(array('type' => 'page')); 

and the TOC is generated following the other contents. But when I open the generated file and try to update the TOC, I get the following error 'Creating a table of contents? Start by applying a heading style from the Styles gallery to the selected text. Any idea guys what this could be ?