How to repeat a particular paragraph or Node in a word document

I have 2 Requirements

  1. I want to repeat a particular paragraph which is in section in a word document.
    here word document divided into sections, in sections we have paragraphs like below
    Ex:-
    Section start
    a.That the Financial Statements of the Company for the financial year ended [FYE] together with the Director(s)’ Report and Statement thereon be hereby received and adopted.
    b. Second paragraph.
    c. Third paragraph.
    Section end

above case i want to repeat “a” point

  1. I want to repeat a particular paragraph which is in a paragraph(para in a para) all are under a section
    Ex:-
    Section Start
  2. TO RECEIVE AND ADOPT FINANCIAL STATEMENTS FOR THE YEAR ENDED [FYE]
    a. First paragraph.
    b. That the Financial Statements of the Company for the financial year ended [FYE] together with the Director(s)’ Report and Statement thereon be hereby received and adopted.
    c. Third paragraph.
    #Section End
    here i need to repeat “b” point
PageNumberFinder finder = new PageNumberFinder(doc);

// Split nodes which are found across pages.
finder.SplitNodesAcrossPages(true);

// Copy all content including headers and footers from the specified pages into the //destination document.
ArrayList pageSections = finder.RetrieveAllNodesOnPages(1, doc.Sections.Count, NodeType.Section);
// Sample DataTable which is having Keys and Values
System.Data.DataTable dt = GetDataTable();

int sectionCount = 0;
foreach (Section section in pageSections)
{
    NodeCollection paragraphs = section.GetChildNodes(NodeType.Paragraph, true);

    for (int i = 0; i < paragraphs.Count; i++)
    {
        string text = paragraphs[i].Range.Text;
        if (i == 10)
            // Here i need to add 10th Para to Section in both cases
    }
}

Please help me how to do ?

Hi Sudheer,

Thanks for your inquiry. Please use the CompositeNode.InsertAfter method to insert the specified node immediately after the specified reference node. If refChild is null, inserts newChild at the beginning of the list of child nodes.

If the node being inserted was created from another document, you should use ImportNode to import the node to the current document. The imported node can then be inserted into the current document.

Please check the highlighted code below. In both scenarios, please use CompositeNode.InsertAfter method. I suggest you please read the members of CompositeNode from here:
https://reference.aspose.com/words/net/aspose.words/compositenode/

If you still face problem, please share your input and expected output document here for our reference. We will then provide you more information about your query along with code.

Document doc = new Document(MyDir + "Test001.docx");
NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
for (int i = 0; i < paragraphs.Count; i++)
{
    string text = paragraphs[i].Range.Text;
    if (i == 10)
    {
        Paragraph para = (Paragraph)paragraphs[i].Clone(true);
        ((Paragraph)paragraphs[i]).ParentNode.InsertAfter(para, paragraphs[i]);
    }
}
doc.Save(MyDir + "Out.docx");