I am using PHPWord library to convert my HTML document to Docx file.
I have issue in generating TOC(Table of contents) correctly in Word document. In HTML, TOC is created by # linking of anchor tags with divs and working perfectly. How can i convert it to Docx TOC using PHPWord?
My code to generate HTML to Docx is as follows:
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
\PhpOffice\PhpWord\Shared\Html::addHtml($section,$htmlContent);
$targetFile = __DIR__ . "/convertedFile.docx";
$phpWord->save($targetFile, 'Word2007');
Library link: PHPWord