Bladeren bron

This patch adds the ability to access the text of Endnotes and Footnotes defined within a document, otherwise hidden behind an internal XDocument field.

Reason: I was attempting to replicate the functionality of the Interop word-count facility: Document.ComputeStatistics(WdStatistic.wdStatisticWords) which takes IncludeFootnotesAndEndnotes as a boolean parameter. The DocX.Text property does not include endnotes or footnotes (which is fine), but I needed the extra properties to be able to access them when IncludeFootnotesAndEndnotes is true.

Patch provided by Tweet
master
MadBoy_cp 11 jaren geleden
bovenliggende
commit
4ec4d334c2
1 gewijzigde bestanden met toevoegingen van 29 en 0 verwijderingen
  1. 29
    0
      DocX/DocX.cs

+ 29
- 0
DocX/DocX.cs Bestand weergeven

@@ -882,6 +882,35 @@ namespace Novacode
return HelperFunctions.GetText(Xml);
}
}
/// <summary>
/// Get the text of each footnote from this document
/// </summary>
public IEnumerable<string> FootnotesText
{
get
{
foreach (XElement footnote in footnotes.Root.Elements(w + "footnote"))
{
yield return HelperFunctions.GetText(footnote);
}
}
}
/// <summary>
/// Get the text of each endnote from this document
/// </summary>
public IEnumerable<string> EndnotesText
{
get
{
foreach (XElement endnote in endnotes.Root.Elements(w + "endnote"))
{
yield return HelperFunctions.GetText(endnote);
}
}
}
internal string GetCollectiveText(List<PackagePart> list)
{

Laden…
Annuleren
Opslaan