Closed A10s closed 1 year ago
I don't think it's currently supported. Neither are endnotes.
thanks for the quick response
By not supported I mean they are not directly exposed in easy to use way - but with some effort you could get them. Probaby easier to add this functionality into officeimo for others to use.
Can you make a small example, how I get the footnotes from the document? I currently need to replace all hyperlinks in a project, including those in footnotes.
It's probably easier to add some support for it. Not sure if i will have time, but I'll play with it soon
@A10s while I am not done with the PR, maybe this is something that will get you started already. You can add, find foot notes and modify them for now. If you're willing to compile your own version it may be just what you need for now. I'll probably finish it in few days if i get enough time. End notes are not done either.
Thanks for the answer. I've already found how to get to the footnotes and the hyperlinks they contain
my code:
var doc=WordDocument.Load("test.docx");
var footnotesPart = doc._document.MainDocumentPart?.FootnotesPart;
if (footnotesPart != null)
{
var footnotes = footnotesPart.Footnotes.Elements<Footnote>();
foreach (var f in footnotes)
{
var hyperlinks = f.Descendants<Hyperlink>();
foreach (var hyp in hyperlinks)
{
var id=hyp.Id;
var hrs=footnotesPart .HyperlinkRelationships.Single(q => q.Id == id);
var uri= hrs.Uri;
........
}
}}
As long as it works for you ;) My implementation is a bit more complex, but it just simplifies things.
using (WordDocument document = WordDocument.Load(filePath)) {
foreach (var footNote in document.FootNotes) {
foreach (var paragraph1 in footNote.Paragraphs) {
if (paragraph1.IsHyperLink) {
paragraph1.Hyperlink.Text = "xxx";
}
}
}
}
Thank you for your support!
How can I find the footnotes of a Word document?