BodyParentSection Property |
Namespace: Aspose.Words
ParentSection is equivalent to (Section)ParentNode.
public void SuppressEndnotes() { // Create a new document and make it empty Document doc = new Document(); doc.RemoveAllChildren(); // Normally endnotes are all stored at the end of a document, but this option lets us store them at the end of each section doc.EndnoteOptions.Position = EndnotePosition.EndOfSection; // Create 3 new sections, each having a paragraph and an endnote at the end InsertSection(doc, "Section 1", "Endnote 1, will stay in section 1"); InsertSection(doc, "Section 2", "Endnote 2, will be pushed down to section 3"); InsertSection(doc, "Section 3", "Endnote 3, will stay in section 3"); // Each section contains its own page setup object // Setting this value will push this section's endnotes down to the next section PageSetup pageSetup = doc.Sections[1].PageSetup; pageSetup.SuppressEndnotes = true; doc.Save(ArtifactsDir + "PageSetup.SuppressEndnotes.docx"); } /// <summary> /// Add a section to the end of a document, give it a body and a paragraph, then add text and an endnote to that paragraph. /// </summary> private static void InsertSection(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); }