Forum


Replies: 1   Views: 1876
Working example on html_extended footer?
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  · 18-12-2019 - 10:27

Hello,

phpdocx_text and other tags are added as block content; this is the same than using addText standalone. But this tag doesn't replicate the behaviour of:

$text = array();
$text[] = $footerImage;
$text[] = $pageNumber;
$text[] = $divider;
$text[] = $docTitle;

This is adding several elements into a single paragraph as inline contents.

Using HTMLExtended, we recommend you to add the contents using a table, as the included example Core/embedHTML/sample_7.php:

$html = '
    <head>
        <style>
            p {font-style: italic;}
            p.header {font-size: 20px; font-weight: bold;}
            div.footer {font-size: 10px;}
        </style>
    </head>
    <phpdocx_header data-type="default">
        <p class="header">
            Custom header <strong>with strong style</strong>
            <phpdocx_link data-text="External link" data-url="http://www.google.es" />
        </p>
    </phpdocx_header>
    <p>Lorem ipsum dolor sit amet.</p>
    <phpdocx_footer>
        <div class="footer">
            <table border="1" style="border-collapse: collapse" width="600">
                <tbody>
                    <tr width="600">
                        <td>Cell A</td>
                        <td><img src="../../img/image.png" width="35" height="35" style="vertical-align: -15px"></p></td>
                        <td><phpdocx_pagenumber data-target="defaultFooter" data-type="page-of" data-textAlign="right" /></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </phpdocx_footer>
';

$docx->embedHTML($html, array('useHTMLExtended' => true));

This same sample adds an image to the footer and the output is correctly. Please run it and check the output; for footers and headers please use img tag instead of phpdocx_image.
The next version of HTML Extended will include support to set a target when adding contents to footers and headers (as phpdocx_image needs).

Regards.