I have 2 Requirements
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:
http://www.aspose.com/docs/display/wordsnet/CompositeNode+Members
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]);
}
}
<span style=“font-size:9.5pt;line-height:200%;font-family:Consolas;mso-fareast-font-family:
“Times New Roman”;mso-ansi-language:EN-US;mso-fareast-language:EN-US;
mso-bidi-language:AR-SA”>doc.Save(MyDir + “Out.docx”);
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>AR-SA</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
<![endif]–>