Im looking at the sample code at http://www.phpdocx.com/api-documentation/word-content/add-table-of-contents-TOC-Word-document-with-PHP
What is crazyTOC.docx suppossed to be ?
Is there a full blown example of this ?
Thanks
Im looking at the sample code at http://www.phpdocx.com/api-documentation/word-content/add-table-of-contents-TOC-Word-document-with-PHP
What is crazyTOC.docx suppossed to be ?
Is there a full blown example of this ?
Thanks
Hello,
The example available on that page is complete. As you can read on this same page, the third parameter allows to use a TOC style from an existing DOCX; this parameter is optional.
Regards.
Im adding html to the docx using embedHTML.
How do I insert legend to it ?
$html = "";
$html .= "
<h1>Section 1</h1>
...
<h1>Section 2</h1>
<h2>Success Factors</h2>
...
"
$docx->embedHTML($html);
Hello,
If you mean you need to fill the TOC using embedHtml, you can do that using headings tag. We recommend you to read the information available on:
http://www.phpdocx.com/documentation/introduction/html-to-word-PHP
Regards.
I can't seem to get the Table of Contents to work with CreateDocxFromTemplate.
Hello,
If you need to add TOC in a template you need to add it when you create the document or use the MultiMerge class to merge it into the document.
Regards.
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.
Hello,
The addTableContents method allows to add a TOC in documents created from scratch. If you need a TOC when you use a template, you just need to add it in the DOCX when you create the template using Word, LibreOffice, OpenOffice...
Or as explained previously, you can use the MutiMerge class to merge a template with a TOC create from scratch.
Regards.