Forum


Replies: 10   Views: 4211
Footnotes and embedhtml()
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 shroom  · 21-12-2015 - 18:59

This is what I have so far, and it works as far as linking the footnotes, but how should I process the HTML?

.............
$docx = new CreateDocx();

$mytext     = 'The quick <em>brown fox</em>[fn] jumped over the lazy <strong>sleeping dog</strong>.[fn]  And the story continues...';
$footnotes  = 'footnote for the italicized brown fox~~footnote for the bolded sleeping dog~~';

$artext = explode('[fn]', $mytext);
$arfoot = explode('~~', $footnotes);

$text = array();

for ($ni=0;$ni<sizeof($artext);$ni++) {
    if($arfoot[$ni]!=''){
        $tmp = new WordFragment($docx, 'document');
        $tmp->addFootnote(
            array(
                'textDocument' => $artext[$ni],
                'textFootnote' => $arfoot[$ni],
            )
        );
    }else{
        $tmp = array('text' => $artext[$ni]);
    }
                $text[] = $tmp;
}

$docx->addText($text);

$docx->createDocxAndDownload('mySample');

Thanks.