PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.29k stars 2.7k forks source link

Get footnotes twice #2418

Open Zoolootooy opened 1 year ago

Zoolootooy commented 1 year ago

I'm trying to get footnotes from a document, but for some reason I'm getting it twice.

 $phpWord = IOFactory::load('./Test.docx');
 $content = '';
 $footnotes = $phpWord->getFootnotes()->getItems();
//Here I already have all footnotes twice
foreach ($footnotes as $footnote) {
    $string = '';
    foreach ($footnote->getElements() as $element) {
        if ($element instanceof \PhpOffice\PhpWord\Element\Text) {
            $string .= strlen($element->getText()) > 0 ?trim($element->getText()) . ' ' : '';
        }
//                $string .=  ' ';
    }
    $content .= $string . PHP_EOL;
}

Any ideas why this is happening?

Progi1984 commented 1 year ago

@Zoolootooy Could you a sample file ?