File tree Expand file tree Collapse file tree
Word-document/Clone-and-merge-two-documents/.NET/Clone-and-merge-two-documents Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using Syncfusion . DocIO ;
22using Syncfusion . DocIO . DLS ;
3- using System ;
43using System . IO ;
54
6- namespace Clone_whole_Word_document
5+ //Opens the source document
6+ FileStream SourceFileStream = new FileStream ( @"../../../Data/SourceDocument.docx" , FileMode . Open ) ;
7+ WordDocument sourceDocument = new WordDocument ( SourceFileStream , FormatType . Docx ) ;
8+ //Opens the destination document
9+ FileStream DestinationFileStream = new FileStream ( @"../../../Data/DestinationDocument.docx" , FileMode . Open ) ;
10+ WordDocument destinationDocument = new WordDocument ( DestinationFileStream , FormatType . Docx ) ;
11+ //Processes the body contents for each section in the Word document
12+ foreach ( WSection section in sourceDocument . Sections )
713{
8- class Program
14+ //Accesses the body of section where all the contents in document are apart
15+ foreach ( TextBodyItem bodyItem in section . Body . ChildEntities )
916 {
10- static void Main ( string [ ] args )
11- {
12-
13- }
17+ destinationDocument . LastSection . Body . ChildEntities . Add ( bodyItem . Clone ( ) ) ;
1418 }
1519}
20+ //Closes the source document
21+ sourceDocument . Close ( ) ;
22+ destinationDocument . Save ( @"../../../Output/Output.docx" , FormatType . Docx ) ;
23+ //Closes the destination document
24+ destinationDocument . Close ( ) ;
You can’t perform that action at this time.
0 commit comments