getParentWriter()->getPhpWord(); $content = ''; $content .= '' . PHP_EOL; $sections = $phpWord->getSections(); foreach ($sections as $section) { $writer = new Container($this->getParentWriter(), $section); $content .= $writer->write(); } $content .= $this->writeNotes(); $content .= '' . PHP_EOL; return $content; } /** * Write footnote/endnote contents as textruns * * @return string */ private function writeNotes() { /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ $parentWriter = $this->getParentWriter(); $phpWord = $parentWriter->getPhpWord(); $notes = $parentWriter->getNotes(); $content = ''; if (!empty($notes)) { $content .= '
' . PHP_EOL; foreach ($notes as $noteId => $noteMark) { list($noteType, $noteTypeId) = explode('-', $noteMark); $method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes'); $collection = $phpWord->$method()->getItems(); if (isset($collection[$noteTypeId])) { $element = $collection[$noteTypeId]; $noteAnchor = ""; $noteAnchor .= "{$noteId}"; $writer = new TextRunWriter($this->getParentWriter(), $element); $writer->setOpeningText($noteAnchor); $content .= $writer->write(); } } } return $content; } }