Forum


Replies: 11   Views: 5092
Addtablecontents in a specific page
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 aldo.scrivanti@poch.cl  · 19-07-2016 - 13:29

ok  in my template add a table of content from Word  but nothing happeng  But if I add $docx->addTableContents update the table of content  but is add another table of content at end of document

//variable is just a example

$docx = new Phpdocx\Create\CreateDocxFromTemplate('Informe.docx');

$docx->replaceVariableByHTML('clienteNombre', 'inline', $variable, $estiloHtml);

$docx->replaceVariableByHTML('Propuesta', 'inline', $variable , $estiloHtml);

$docx->replaceVariableByText(array('PortadaNombreProyecto' =>$variable), array());


$org  = $something;


if($org ){         
        $docx->replaceVariableByHTML('ORG', 'block', $variable, $estiloHtml);
    
}else{
    $docx->deleteTemplateBlock('ORG');                 
}

$docx->addTableContents(array('autoUpdate' => true), $legend);

$docx->clearBlocks();

$legend = array( 
    'color' => 'B70000', 
    'bold' => true, 
    'fontSize' => 12,
    'pageBreakBefore' => true
    );
    
$docx->addTableContents(array('autoUpdate' => true), $legend);
    
/* Le damos un nombre random  */
$nombreInforme = "Poch_".str_replace(" ", "_", $variable)."_".date("Y-m-d");

/* Obligamos a que descargue  */
$docx->createDocxAndDownload($nombreInforme);