Forum


Replies: 2   Views: 388
Footnote element affects image or hyperlink preceding it using html extended
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 dev@ams  · 21-09-2021 - 06:54

Hi there,

I'm wondering if this is a familiar problem. When we create documents where an image is followed by a paragraph – either directly or with a 'normal' paragraph in between – that contains a footnote, the image is not included in the docx file. Removing the footnote will result in the image appearing in the docx file. 

Similarly, when a paragraph containing a hyperlink is followed by a paragraph containing a footnote, the hyperlink is not 'clickable' in the docx file (meaning that you cannot click it to open the link). However, removing the footnote results in the hyperlink fo the clickable in the created docx file.

Example snippet:

<p>aaa</p>
<p><img src="{some_logo_removed_for_example_purposes}" class="image" /></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>

 

Posted by admin  · 21-09-2021 - 09:51

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.