A.doc have 5 paragraphs
b.doc have 7 paragraphs
How can i insert paragraphs[2] from A.doc to b.doc between paragraphs[2] and paragraphs[3] ?
pray the answer
Thank you !!
The NodeImporter class allows to efficiently perform repeated import of nodes from one document to another. You can use NodeImporter.ImportNode method to import a node from one document into another.
Following code example shows how to import paragraph from one paragraph to another.
Document dstDoc = new Document(MyDir + "A.docx");
Document srcDoc = new Document(MyDir + "B.docx");
NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting);
Paragraph srcPara = srcDoc.FirstSection.Body.Paragraphs[2];
Node importedNode = importer.ImportNode(srcPara, true);
dstDoc.FirstSection.Body.InsertAfter(importedNode, dstDoc.FirstSection.Body.Paragraphs[2]);
dstDoc.Save(MyDir + "19.7.docx");
Thank you very much!
This was quite helpful!
The code works vell.