Forum


Replies: 7   Views: 4318
Table of contents : how to ?
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 davelavinsky  · 27-04-2016 - 16:24

I did everything in the example mentioned in the doc. Only line that was changed was :

$docx = new CreateDocxFromTemplate("template.docx");

<?php
require_once 'path/to/phpdocx/phpdocx-corporate-5.5/classes/CreateDocx.inc';

$docx = new CreateDocxFromTemplate("template.docx");

$docx->addText('Table of Contents', array('bold' => true, 'fontSize' => 14));

$legend = array('text' => 'Click here to update the TOC', 
'color' => 'B70000', 
'bold' => true, 
'fontSize' => 12);
$docx->addTableContents(array('autoUpdate' => true), $legend);

//we add now some headings so tehy show up in the TOC
$docx->addText('Chapter 1', array('pStyle' => 'Heading1PHPDOCX'));
$docx->addText('Section', array('pStyle' => 'Heading2PHPDOCX'));
$docx->addText('Another TOC entry', array('pStyle' => 'Heading3PHPDOCX'));

$docx->createDocx('example_addTableContents_1');    
?>

And the Table of Contents did not get generated. Only the text as it is.