Forum


Replies: 5   Views: 3378
Toc: not working links to chapters
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 admin  · 07-06-2018 - 11:44

Hello,

Thanks for the code. The problem is that you are adding blank spaces in the anchor (and some DOCX readers may don't support them), and the element to generate the bookmark must be added after the element.

This is a simple sample:

$html = "
    <html>
        <body>
            <br>UnisefPolicy 1
            <h1>Sommario</h1>
            <br>
            <h4><a href='#1InformazioniGenerali'>1. Informazioni Generali</a></h4>
            <h4><a href='#2SistemiInformativieSicurezzadeiDati'>2. Sistemi Informativi e Sicurezza dei Dati</a></h4>
            <br>Other text<br>
            <h3>1. Informazioni Generali</h3>
            <div id='1InformazioniGenerali'></div>
            <br>Other text<br>
            <h3>2. Sistemi Informativi e Sicurezza dei Dati</h3>
            <div id='2SistemiInformativieSicurezzadeiDati'></div>
        </body>
    </html>";

$options = array('parseAnchors'=> true,'baseUrl'=>'//','downloadImages' => true);

About showing the file path, it's the default behaviour of Word. We recommend you to use Table of contents to accomplish what you need.

Regards.