Hello,
As general recommendation when using HTML Extended, if you need to mix elements with external relationships (such as img and link tags mixed with footnotes, comments, endnotes, headers or footers), we recommend using HTML Extented tags to add those elements (the elements that have external relationships):
$html = '
<p>aaa</p>
<p><phpdocx_image data-src="image.png" /></p>
<p>bbbb</p>
<phpdocx_footnote>
<p>Here comes the </p>
<phpdocx_footnote_textdocument data-text=" footnote " data-italic="true" />
<phpdocx_footnote_textfootnote>
<p class="italicc">Text <strong>footnote</strong></p>
</phpdocx_footnote_textfootnote>
<p>and some other text.</p>
</phpdocx_footnote>
';
$docx->embedHTML($html, array('useHTMLExtended' => true));
or add the content in two steps:
$html = '
<p>aaa</p>
<p><img src="image.png" class="image" /></p>
<p>bbbb</p>
';
$docx->embedHTML($html, array('useHTMLExtended' => true));
$html = '
<phpdocx_footnote>
<p>Here comes the </p>
<phpdocx_footnote_textdocument data-text=" footnote " data-italic="true" />
<phpdocx_footnote_textfootnote>
<p class="italicc">Text <strong>footnote</strong></p>
</phpdocx_footnote_textfootnote>
<p>and some other text.</p>
</phpdocx_footnote>
';
$docx->embedHTML($html, array('useHTMLExtended' => true));
or add placeholders and the replace them by WordFragments as explained on https://www.phpdocx.com/documentation/snippets/add-footnote-block-content-inline-html-extended.
We have also added a task to the dev team to improve mixing tags with external relationships when using HTML Extended tags and regular HTML tags at the same time.
Regards.