Reza M.A
Reza M.A

Reputation: 1207

retrieve footnote of word file with openxml

How can retrieve all footnotes of a word file in c# using open xml, i know that we can retrieve the paragraphs with some things like this:

IEnumerable<Paragraph> paragraphs = mainPart.Document.Body.OfType<Paragraph>();

but when i test it for footnotes i just get the null while i know there is some footnotes in my word file.

i have just find this pages to help me on this problem, but they didn't help me:

Footnotes constructor

how can i get all the footnotes and save theme in a list.

Upvotes: 1

Views: 994

Answers (1)

Example to get the footnotes:

FootnotesPart footnotesPart = wordDoc.MainDocumentPart.FootnotesPart;
if (footnotesPart != null)
{
    IEnumerable<Footnote> footnotes = footnotesPart.Footnotes.Elements<Footnote>();
    ...
}

Upvotes: 1

Related Questions