Click or drag to resize

ElementClone Method

Clones this element instance.

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.7.18
public Element Clone(
	bool cloneDescendants


cloneDescendants  Boolean
to clone all descendants.

Return Value

The cloned element.

This method serves as a copy constructor for elements. The cloned element has no parent, but belongs to the same document as the original element.

If you want to insert this element into another document, then you should first import it into another document with ImportT(T, Boolean) method and then insert the imported element.


See Developer Guide: How to clone an element in DOCX document

How to clone an element in DOCX document in C#
using System;
using SautinSoft.Document;
using System.IO;
using System.Linq;
using System.Text;

namespace Sample
    class Sample
        static void Main(string[] args)
            // Get your free 100-day key here:   


        /// <summary>
        /// How to clone an element in DOCX document.
        /// </summary>
        /// <remarks>
        /// Details:
        /// </remarks>
        static void CloningElement()
            string filePath = @"..\..\..\Parsing.docx";
            string cloningFile = "Cloning.docx";
            DocumentCore dc = DocumentCore.Load(filePath);

            // Clone section.

            // Clone paragraphs.
            foreach (Block item in dc.Sections[0].Blocks)

            // Save the result.

            // Show the result.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(filePath) { UseShellExecute = true });
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(cloningFile) { UseShellExecute = true });
How to clone an element in DOCX document in VB.Net
Imports System
Imports SautinSoft.Document
Imports System.IO
Imports System.Linq
Imports System.Text

Module Sample
    Sub Main()
    End Sub
    ''' Get your free 100-day key here:   
    ''' <summary>
    ''' How to clone an element in DOCX document.
    ''' </summary>
    ''' <remarks>
    ''' Details:
    ''' </remarks>
    Sub CloningElement()
        Dim filePath As String = "..\..\..\Parsing.docx"
        Dim cloningFile As String = "Cloning.docx"
        Dim dc As DocumentCore = DocumentCore.Load(filePath)

        ' Clone section.

        ' Clone paragraphs.
        For Each item As Block In dc.Sections(0).Blocks
        Next item

        ' Save the result.

        ' Show the results.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(filePath) With {.UseShellExecute = True})
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(cloningFile) With {.UseShellExecute = True})
    End Sub
End Module
See Also