Hi Nitin,
Thanks for sharing the details. I have read your Object Model and suggest you following code snippet. You can get idea from following code snippet and use it in your application. Please also read following documentation links for your kind reference.
http://www.aspose.com/docs/display/wordsnet/How+to++Insert+a+Document+into+another+Document
http://www.aspose.com/docs/display/wordsnet/DocumentBuilder+Class
https://reference.aspose.com/words/net/aspose.words/documentbuilder/
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>PL</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:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<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]>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:10.0pt;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:47.9pt;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:"Times New Roman";
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:Arial;
mso-bidi-theme-font:minor-bidi;}
<![endif]–>
Document FinalDoc = new
Document();
DocumentBuilder builder = new DocumentBuilder(FinalDoc);
builder.MoveTo(FinalDoc.FirstSection.Body.FirstParagraph);
//Object 1: Filepath to an image (.jpg) file
Shape image = builder.InsertImage("d:\\Chrysanthemum.jpg");
//Object 2: RTF Content (Title and some Copyright information)
Document docChapter1Title =
RtfStringToDocument("chapter 1 title RTF
STring");
Paragraph paragraph =
builder.InsertParagraph();
InsertDocument(paragraph,
docChapter1Title);
builder.Writeln("");
builder.ParagraphFormat.StyleIdentifier
= StyleIdentifier.Heading1;
builder.Font.Color
= Color.Blue;
builder.Writeln("Table of Contents ");
builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");
builder.Writeln("");
//Object 3: How We came to Mexico (This is JUST the first chapter's title text
and is in RTF format)
builder.Writeln("How We Came to Mexico");
builder.ParagraphFormat.StyleIdentifier
= StyleIdentifier.Normal;
builder.Font.Color = Color.Black;
//Object 4: RTF Content - This is the content that belongs to
the above chapter
builder.Writeln(@"It started on the beaches, both in Ixtapa, on the
Pacific coast, and Playa del Carmen on the Gulf. In the 90s we began to come
down for ....");
builder.Writeln("");
builder.ParagraphFormat.StyleIdentifier
= StyleIdentifier.Heading2;
builder.Font.Color = Color.Blue;
builder.Writeln("A Word of Protest");
builder.ParagraphFormat.StyleIdentifier
= StyleIdentifier.Normal;
builder.Font.Color
= Color.Black;
builder.Writeln(@"One of the points I made in the Conclusions
section of my book on the expatriate experience, San Miguel de Allende: a Pla
.....");
FinalDoc.UpdateFields();
FinalDoc.Save(MyDir + "AsposeOut.doc", SaveFormat.Doc);
public void InsertDocument(Node insertAfterNode, Document
srcDoc)
{
// Make sure that
the node is either a paragraph or table.
if
((!insertAfterNode.NodeType.Equals(NodeType.Paragraph))
&
(!insertAfterNode.NodeType.Equals(NodeType.Table)))
throw new ArgumentException("The destination node should be either a paragraph
or table.");
// We will be
inserting into the parent of the destination paragraph.
CompositeNode
dstStory = insertAfterNode.ParentNode;
// This object
will be translating styles and lists during the import.
NodeImporter
importer = new NodeImporter(srcDoc,
insertAfterNode.Document, ImportFormatMode.KeepSourceFormatting);
// Loop through
all sections in the source document.
foreach (Section srcSection in
srcDoc.Sections)
{
// Loop
through all block level nodes (paragraphs and tables) in the body of the
section.
foreach
(Node srcNode in
srcSection.Body)
{
// Let's
skip the node if it is a last empty paragraph in a section.
if
(srcNode.NodeType.Equals(NodeType.Paragraph))
{
Paragraph
para = (Paragraph)srcNode;
if
(para.IsEndOfSection && !para.HasChildNodes)
continue;
}
// This
creates a clone of the node, suitable for insertion into the destination
document.
Node
newNode = importer.ImportNode(srcNode, true);
// Insert
new node after the reference node.
dstStory.InsertAfter(newNode, insertAfterNode);
insertAfterNode = newNode;
}
}
}
Please let us know if you have any more queries.