Skip to content

Commit 68c78b1

Browse files
author
Konduru Keerthi Konduru Ravichandra Raju
committed
Orientation
1 parent ca386ed commit 68c78b1

File tree

1 file changed

+14
-8
lines changed
  • Sections/Set-different-orientation/.NET/Set-different-orientation

1 file changed

+14
-8
lines changed

Sections/Set-different-orientation/.NET/Set-different-orientation/Program.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
using 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

Comments
 (0)