PageSetupOrientation Property

Returns or sets the orientation of the page.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.10.0


public Orientation Orientation { get; set; }

Property Value

Type: Orientation


Changing Orientation swaps PageWidth and PageHeight.


Shows how to insert sections using DocumentBuilder, specify page setup for a section and reset page setup to defaults.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Modify the first section in the document
builder.PageSetup.Orientation = Orientation.Landscape;
builder.PageSetup.VerticalAlignment = PageVerticalAlignment.Center;
builder.Writeln("Section 1, landscape oriented and text vertically centered.");

// Start a new section and reset its formatting to defaults
builder.Writeln("Section 2, back to default Letter paper size, portrait orientation and top alignment.");

doc.Save(ArtifactsDir + "PageSetup.ClearFormatting.docx");
Shows how to adjust paper size, orientation, margins and other settings for a section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.PageSetup.PaperSize = PaperSize.Legal;
builder.PageSetup.Orientation = Orientation.Landscape;
builder.PageSetup.TopMargin = ConvertUtil.InchToPoint(1.0);
builder.PageSetup.BottomMargin = ConvertUtil.InchToPoint(1.0);
builder.PageSetup.LeftMargin = ConvertUtil.InchToPoint(1.5);
builder.PageSetup.RightMargin = ConvertUtil.InchToPoint(1.5);
builder.PageSetup.HeaderDistance = ConvertUtil.InchToPoint(0.2);
builder.PageSetup.FooterDistance = ConvertUtil.InchToPoint(0.2);

builder.Writeln("Hello world.");

doc.Save(ArtifactsDir + "PageSetup.PageMargins.docx");

ExpandedSee Also