|
1 | 1 | using Syncfusion.DocIO.DLS; |
2 | 2 | using Syncfusion.DocIO; |
3 | 3 |
|
4 | | -using (FileStream sourceStream = new FileStream(Path.GetFullPath(@"Data/SourceDocument.docx"), FileMode.Open, FileAccess.ReadWrite)) |
| 4 | +using (FileStream destinationStream = new FileStream(Path.GetFullPath(@"Data/DestinationDocument.docx"), FileMode.Open, FileAccess.ReadWrite)) |
5 | 5 | { |
6 | 6 | //Open the source document. |
7 | | - using (WordDocument sourceDocument = new WordDocument(sourceStream, FormatType.Docx)) |
| 7 | + using (WordDocument destinationDocument = new WordDocument(destinationStream, FormatType.Docx)) |
8 | 8 | { |
9 | | - using (FileStream destinationStream = new FileStream(Path.GetFullPath(@"Data/DestinationDocument.docx"), FileMode.Open, FileAccess.ReadWrite)) |
| 9 | + using (FileStream sourceStream = new FileStream(Path.GetFullPath(@"Data/SourceDocument.docx"), FileMode.Open, FileAccess.ReadWrite)) |
10 | 10 | { |
11 | 11 | //Open the destination document. |
12 | | - using (WordDocument destinationDocument = new WordDocument(destinationStream, FormatType.Docx)) |
| 12 | + using (WordDocument sourceDocument = new WordDocument(sourceStream, FormatType.Docx)) |
13 | 13 | { |
14 | | - //Get the style from source document. |
| 14 | + // Retrieve the specific style from the source document. |
15 | 15 | WParagraphStyle paraStyle = sourceDocument.Styles.FindByName("MyStyle") as WParagraphStyle; |
16 | | - //Add it into destination document. |
| 16 | + // Add the retrieved style to the destination document. |
17 | 17 | destinationDocument.Styles.Add(paraStyle.Clone()); |
18 | | - //Get the first paragraph in destination document. |
| 18 | + // Get the first paragraph in the destination document. |
19 | 19 | WParagraph paragraph = destinationDocument.Sections[0].Body.ChildEntities[0] as WParagraph; |
20 | | - //Applies the new style to paragraph. |
| 20 | + // Apply the retrieved style to the paragraph in the destination document. |
21 | 21 | paragraph.ApplyStyle("MyStyle"); |
22 | | - //Saves the destination document. |
| 22 | + // Save the destination document. |
23 | 23 | using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) |
24 | 24 | { |
25 | 25 | destinationDocument.Save(outputStream, FormatType.Docx); |
|
0 commit comments