22using Syncfusion . DocIO ;
33
44//Open an existing document
5- using ( WordDocument document = new WordDocument ( new FileStream ( @"../../../Data/Template.docx" , FileMode . Open , FileAccess . Read ) , FormatType . Docx ) )
5+ using ( FileStream inputStream = new FileStream ( @"../../../Data/Template.docx" , FileMode . Open , FileAccess . Read ) )
66{
7- //Set different orientations
8- document . Sections [ 0 ] . PageSetup . Orientation = PageOrientation . Portrait ;
9- document . Sections [ 1 ] . PageSetup . Orientation = PageOrientation . Landscape ;
10- document . Sections [ 2 ] . PageSetup . Orientation = PageOrientation . Portrait ;
11- document . Sections [ 3 ] . PageSetup . Orientation = PageOrientation . Landscape ;
7+ using ( WordDocument document = new WordDocument ( inputStream , FormatType . Docx ) )
8+ {
9+ //Set different orientations
10+ document . Sections [ 0 ] . PageSetup . Orientation = PageOrientation . Portrait ;
11+ document . Sections [ 1 ] . PageSetup . Orientation = PageOrientation . Landscape ;
12+ document . Sections [ 2 ] . PageSetup . Orientation = PageOrientation . Portrait ;
13+ document . Sections [ 3 ] . PageSetup . Orientation = PageOrientation . Landscape ;
1214
13- //Save the Word document
14- document . Save ( new FileStream ( @"../../../Output.docx" , FileMode . Create , FileAccess . Write ) , FormatType . Docx ) ;
15+ //Save the Word document
16+ using ( FileStream outputStream = new FileStream ( @"../../../Output.docx" , FileMode . Create , FileAccess . Write ) )
17+ {
18+ document . Save ( outputStream , FormatType . Docx ) ;
19+ }
20+ }
1521}
0 commit comments