SectionClone Method

Creates a duplicate of this section.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public Section Clone()

Return Value

Type: Section


Shows how to add/remove sections in a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Write("Section 1");
builder.Write("Section 2");

// This shows what is in the document originally. The document has two sections
Assert.AreEqual("Section 1\x000cSection 2", doc.GetText().Trim());

// Delete the first section from the document

// Duplicate the last section and append the copy to the end of the document
int lastSectionIdx = doc.Sections.Count - 1;
Section newSection = doc.Sections[lastSectionIdx].Clone();

// Check what the document contains after we changed it
Assert.AreEqual("Section 2\x000cSection 2", doc.GetText().Trim());

See Also