Skip to content

Endnote support is lacking (Word writer) #1703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mdupont opened this issue Aug 26, 2019 · 0 comments
Open

Endnote support is lacking (Word writer) #1703

mdupont opened this issue Aug 26, 2019 · 0 comments

Comments

@mdupont
Copy link
Contributor

mdupont commented Aug 26, 2019

Describe the Bug

Positioning Endnotes is currently not working for 2 reasons:

  1. PHPWord can only set properties for Footnotes, that Endnotes do not use in the final document
  2. AFAICS, Endnotes positioning only works at the whole document level, not at the section level (even if OOXML spec and Word UI say otherwise - tested with multiple versions of Word), but PHPWord has no way to set Endnote properties (nor Footnote properties) at the document level.

Steps to Reproduce

Please provide a code sample that reproduces the issue.

<?php
require __DIR__ . '/vendor/autoload.php';

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$textrun = $section->addTextrun();
$textrun->addText('This is a piece of text with an endnote');
$endnote = $textrun->addEndnote();
$endnote->addText('This endnote should be at the end of the first section, which ends on the first page of this document');

$ep = new PhpOffice\PhpWord\ComplexType\FootnoteProperties();
$ep->setPos(PhpOffice\PhpWord\ComplexType\FootnoteProperties::POSITION_SECTION_END);
$section->setFootnoteProperties($ep);

$section = $phpWord->addSection();
$section->addText('There should not be any endnote below this text');

Expected Behavior

  • Have a way to set Endnote properties at the document level, something like $phpWord->setDefaultEndnoteProperties()
  • These default properties end up being written to the settings.xml file of the .docx output only if there is at least 1 endnote in the document, otherwise Word will complain that the file is corrupted
  • Endnotes in the document are positioned according to the default properties: using POSITION_SECTION_END results in Endnotes being positioned at the end of their section, not the end of the document.

Current Behavior

  • no w:endnotePr element is ever written to document.xml file with the Word writer
  • no w:endnotePr element (or w:footnotePr) is ever written to settings.xml file with the Word writer

Context

Please fill in your environment information:

  • PHP Version: 7.1
  • PHPWord Version: Git, HEAD of develop branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant