ParentSection
Contents
[
Hide
]Body.ParentSection property
Gets the parent section of this story.
public Section ParentSection { get; }
Remarks
ParentSection
is equivalent to ParentNode
casted to Section
.
Examples
Shows how to store endnotes at the end of each section, and modify their positions.
public void SuppressEndnotes()
{
Document doc = new Document();
doc.RemoveAllChildren();
// By default, a document compiles all endnotes at its end.
Assert.AreEqual(EndnotePosition.EndOfDocument, doc.EndnoteOptions.Position);
// We use the "Position" property of the document's "EndnoteOptions" object
// to collect endnotes at the end of each section instead.
doc.EndnoteOptions.Position = EndnotePosition.EndOfSection;
InsertSectionWithEndnote(doc, "Section 1", "Endnote 1, will stay in section 1");
InsertSectionWithEndnote(doc, "Section 2", "Endnote 2, will be pushed down to section 3");
InsertSectionWithEndnote(doc, "Section 3", "Endnote 3, will stay in section 3");
// While getting sections to display their respective endnotes, we can set the "SuppressEndnotes" flag
// of a section's "PageSetup" object to "true" to revert to the default behavior and pass its endnotes
// onto the next section.
PageSetup pageSetup = doc.Sections[1].PageSetup;
pageSetup.SuppressEndnotes = true;
doc.Save(ArtifactsDir + "PageSetup.SuppressEndnotes.docx");
}
/// <summary>
/// Append a section with text and an endnote to a document.
/// </summary>
private static void InsertSectionWithEndnote(Document doc, string sectionBodyText, string endnoteText)
{
Section section = new Section(doc);
doc.AppendChild(section);
Body body = new Body(doc);
section.AppendChild(body);
Assert.AreEqual(section, body.ParentNode);
Paragraph para = new Paragraph(doc);
body.AppendChild(para);
Assert.AreEqual(body, para.ParentNode);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveTo(para);
builder.Write(sectionBodyText);
builder.InsertFootnote(FootnoteType.Endnote, endnoteText);
}
See Also
- class Section
- class Body
- namespace Aspose.Words
- assembly Aspose.Words