-
Notifications
You must be signed in to change notification settings - Fork 573
Description
Describe the bug
Adding an endnote having hyperlink into a document having no existing relationship for an endnote part is not generating proper endnotes.xml.rels file due to which generated document cannot be open using MS word or any other related application.
Screenshots
To Reproduce
Kindly run attached console app to reproduce the issue.
EndnotesWithURLIssue.zip
Observed behavior
If same code is executed (EndnotesPart.AddHyperlinkRelationship) for document already having an existing relationship present for endnotepart then generated document can be opened.
Expected behavior
EndnotesPart.AddHyperlinkRelationship should create a proper endnotes.xml.rels if not present.
Desktop (please complete the following information):
- OS: windows 10
- Office version: 16.0.17628.20188
- .NET Target: 4.8
- DocumentFormat.OpenXml Version: 2.5.0, 3.1.0
Debug Info
Adding below code before adding hyperlink relationship fixes the issue.
if(!document.Package.PartExists(new Uri("/word/_rels/endnotes.xml.rels", UriKind.Relative)))
{
var part = document.Package.CreatePart(new Uri("/word/_rels/endnotes.xml.rels", UriKind.Relative), "application/vnd.openxmlformats-package.relationships+xml");
part.Package.Flush();
}

