Forum


Replies: 3   Views: 627
Add footers when importing html
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 usman-mani6  · 07-02-2023 - 16:51

Hi Everyone,

I am trying to add footer using embedded html.
Below is the code i am trying but it's not working let me know what i am doing wrong here
 

$docx = new \Phpdocx\Create\CreateDocxFromTemplate($tempFilePath);

                $docx->removeFooters();

                $docs = new \Phpdocx\Create\CreateDocx();

                $htmlFooter = '<footer>

                                <div class="footer">

                                    <table border="1" style="border-collapse: collapse" width="600">

                                        <tbody>

                                            <tr width="600">

                                                <td>Cell A</td>

                                                <td><img src="image.png" width="35" height="35" style="vertical-align: -15px" data-textAlign="left"></td>

                                                <td><phpdocx_pagenumber data-target="defaultFooter" data-type="page-of" data-textAlign="right" /></td>

                                            </tr>

                                        </tbody>

                                    </table>

                                </div>

                            </footer>';

                $footerFragment = new \Phpdocx\Elements\WordFragment($docs, 'defaultFooter');

                // $footerFragment->embedHTML($htmlFooter);

                $footerFragment->embedHTML($htmlFooter, array('useHTMLExtended' => true));

                $docs->addFooter(array('default' => $footerFragment));

                $docs->createDocx($tempFilePath);

Thanks