Hello,
phpdocx 11 added support to add block contents inside other block contents using HTML Extended. The following information is for phpdocx 10 and previous versions.
The problem is that you are trying to add a phpdocx block element (a footnote) into a block element, and using the current version of phpdocx they need to be added out of block elements (as sample_7.php illustrates).
You can accomplish this task easily doing two steps: add a placeholder where the footnote needs to be added and then load the DOCX as a template and replace the placeholder by the new footnote:
<?php
require_once 'classes/CreateDocx.php';
$docx = new CreateDocx();
$html = '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<table>
<tbody>
<tr>
<td>
$FOOTNOTE$
</td>
</tr>
</tbody>
</table>
</body>
</html>
';
$docx->embedHTML($html, array('useHTMLExtended' => true));
$docx->createDocx('example_embedHTML_9');
$docx = new CreateDocxFromTemplate('example_embedHTML_9.docx');
$footnote_html = '
<phpdocx_footnote>
Some text here and ...
<phpdocx_footnote_textdocument data-text=" note" data-bold="false" />
<phpdocx_footnote_textfootnote>
<p>footnote data</p>
</phpdocx_footnote_textfootnote>
</phpdocx_footnote>';
$footnote = new WordFragment($docx, 'document');
$footnote->embedHTML($footnote_html, array('useHTMLExtended' => true));
$docx->replaceVariableByWordFragment(array('FOOTNOTE' => $footnote), array('type' => 'block'));
$docx->createDocx('example_embedHTML_9_t.docx');
To get the best performance, as you are using a Premium license you can do all the previous steps using in-memory DOCX instead of saving the first DOCX as a new file to be loaded a template. Please check https://www.phpdocx.com/documentation/cookbook/improve-phpdocx-performance and Performance/returnDocxStructure/sample_1.php example.
phpdocx 11 added support to add block contents inside other block contents using HTML Extended. This information is for phpdocx 10 and previous versions.
Regards.