## PageSetup class

Represents the page setup properties of a section.

To learn more, visit the [Working with Sections](https://docs.aspose.com/words/net/working-with-sections/) documentation article.

```csharp
public class PageSetup
```

## Properties

| Name | Description |
| --- | --- |
| [Bidi](../../aspose.words/pagesetup/bidi/) { get; set; } | Specifies that this section contains bidirectional (complex scripts) text. |
| [BorderAlwaysInFront](../../aspose.words/pagesetup/borderalwaysinfront/) { get; set; } | Specifies where the page border is positioned relative to intersecting texts and objects. |
| [BorderAppliesTo](../../aspose.words/pagesetup/borderappliesto/) { get; set; } | Specifies which pages the page border is printed on. |
| [BorderDistanceFrom](../../aspose.words/pagesetup/borderdistancefrom/) { get; set; } | Gets or sets a value that indicates whether the specified page border is measured from the edge of the page or from the text it surrounds. |
| [Borders](../../aspose.words/pagesetup/borders/) { get; } | Gets a collection of the page borders. |
| [BorderSurroundsFooter](../../aspose.words/pagesetup/bordersurroundsfooter/) { get; set; } | Specifies whether the page border includes or excludes the footer. |
| [BorderSurroundsHeader](../../aspose.words/pagesetup/bordersurroundsheader/) { get; set; } | Specifies whether the page border includes or excludes the header. |
| [BottomMargin](../../aspose.words/pagesetup/bottommargin/) { get; set; } | Returns or sets the distance (in points) between the bottom edge of the page and the bottom boundary of the body text. |
| [ChapterPageSeparator](../../aspose.words/pagesetup/chapterpageseparator/) { get; set; } | Gets or sets the separator character that appears between the chapter number and the page number. |
| [CharactersPerLine](../../aspose.words/pagesetup/charactersperline/) { get; set; } | Gets or sets the number of characters per line in the document grid. |
| [DifferentFirstPageHeaderFooter](../../aspose.words/pagesetup/differentfirstpageheaderfooter/) { get; set; } | True if a different header or footer is used on the first page. |
| [EndnoteOptions](../../aspose.words/pagesetup/endnoteoptions/) { get; } | Provides options that control numbering and positioning of endnotes in this section. |
| [FirstPageTray](../../aspose.words/pagesetup/firstpagetray/) { get; set; } | Gets or sets the paper tray (bin) to use for the first page of a section. The value is implementation (printer) specific. |
| [FooterDistance](../../aspose.words/pagesetup/footerdistance/) { get; set; } | Returns or sets the distance (in points) between the footer and the bottom of the page. |
| [FootnoteOptions](../../aspose.words/pagesetup/footnoteoptions/) { get; } | Provides options that control numbering and positioning of footnotes in this section. |
| [Gutter](../../aspose.words/pagesetup/gutter/) { get; set; } | Gets or sets the amount of extra space added to the margin for document binding. |
| [HeaderDistance](../../aspose.words/pagesetup/headerdistance/) { get; set; } | Returns or sets the distance (in points) between the header and the top of the page. |
| [HeadingLevelForChapter](../../aspose.words/pagesetup/headinglevelforchapter/) { get; set; } | Gets or sets the heading level style that is applied to the chapter titles in the document. |
| [LayoutMode](../../aspose.words/pagesetup/layoutmode/) { get; set; } | Gets or sets the layout mode of this section. |
| [LeftMargin](../../aspose.words/pagesetup/leftmargin/) { get; set; } | Returns or sets the distance (in points) between the left edge of the page and the left boundary of the body text. |
| [LineNumberCountBy](../../aspose.words/pagesetup/linenumbercountby/) { get; set; } | Returns or sets the numeric increment for line numbers. |
| [LineNumberDistanceFromText](../../aspose.words/pagesetup/linenumberdistancefromtext/) { get; set; } | Gets or sets distance between the right edge of line numbers and the left edge of the document. |
| [LineNumberRestartMode](../../aspose.words/pagesetup/linenumberrestartmode/) { get; set; } | Gets or sets the way line numbering runs that is, whether it starts over at the beginning of a new page or section or runs continuously. |
| [LinesPerPage](../../aspose.words/pagesetup/linesperpage/) { get; set; } | Gets or sets the number of lines per page in the document grid. |
| [LineStartingNumber](../../aspose.words/pagesetup/linestartingnumber/) { get; set; } | Gets or sets the starting line number. |
| [Margins](../../aspose.words/pagesetup/margins/) { get; set; } | Returns or sets preset [`Margins`](../margins/) of the page. |
| [MultiplePages](../../aspose.words/pagesetup/multiplepages/) { get; set; } | For multiple page documents, gets or sets how a document is printed or rendered so that it can be bound as a booklet. |
| [OddAndEvenPagesHeaderFooter](../../aspose.words/pagesetup/oddandevenpagesheaderfooter/) { get; set; } | True if the document has different headers and footers for odd-numbered and even-numbered pages. |
| [Orientation](../../aspose.words/pagesetup/orientation/) { get; set; } | Returns or sets the orientation of the page. |
| [OtherPagesTray](../../aspose.words/pagesetup/otherpagestray/) { get; set; } | Gets or sets the paper tray (bin) to be used for all but the first page of a section. The value is implementation (printer) specific. |
| [PageHeight](../../aspose.words/pagesetup/pageheight/) { get; set; } | Returns or sets the height of the page in points. |
| [PageNumberStyle](../../aspose.words/pagesetup/pagenumberstyle/) { get; set; } | Gets or sets the page number format. |
| [PageStartingNumber](../../aspose.words/pagesetup/pagestartingnumber/) { get; set; } | Gets or sets the starting page number of the section. |
| [PageWidth](../../aspose.words/pagesetup/pagewidth/) { get; set; } | Returns or sets the width of the page in points. |
| [PaperSize](../../aspose.words/pagesetup/papersize/) { get; set; } | Returns or sets the paper size. |
| [RestartPageNumbering](../../aspose.words/pagesetup/restartpagenumbering/) { get; set; } | True if page numbering restarts at the beginning of the section. |
| [RightMargin](../../aspose.words/pagesetup/rightmargin/) { get; set; } | Returns or sets the distance (in points) between the right edge of the page and the right boundary of the body text. |
| [RtlGutter](../../aspose.words/pagesetup/rtlgutter/) { get; set; } | Gets or sets whether Microsoft Word uses gutters for the section based on a right-to-left language or a left-to-right language. |
| [SectionStart](../../aspose.words/pagesetup/sectionstart/) { get; set; } | Returns or sets the type of section break for the specified object. |
| [SheetsPerBooklet](../../aspose.words/pagesetup/sheetsperbooklet/) { get; set; } | Returns or sets the number of pages to be included in each booklet. |
| [SuppressEndnotes](../../aspose.words/pagesetup/suppressendnotes/) { get; set; } | True if endnotes are printed at the end of the next section that doesn't suppress endnotes. Suppressed endnotes are printed before the endnotes in that section. |
| [TextColumns](../../aspose.words/pagesetup/textcolumns/) { get; } | Returns a collection that represents the set of text columns. |
| [TextOrientation](../../aspose.words/pagesetup/textorientation/) { get; set; } | Allows to specify [`TextOrientation`](./textorientation/) for the whole page. Default value is Horizontal |
| [TopMargin](../../aspose.words/pagesetup/topmargin/) { get; set; } | Returns or sets the distance (in points) between the top edge of the page and the top boundary of the body text. |
| [VerticalAlignment](../../aspose.words/pagesetup/verticalalignment/) { get; set; } | Returns or sets the vertical alignment of text on each page in a document or section. |

## Methods

| Name | Description |
| --- | --- |
| [ClearFormatting](../../aspose.words/pagesetup/clearformatting/)() | Resets page setup to default paper size, margins and orientation. |

## Remarks

`PageSetup` object contains all the page setup attributes of a section (left margin, bottom margin, paper size, and so on) as properties.

## Examples

Shows how to apply and revert page setup settings to sections in a document.

```csharp
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Modify the page setup properties for the builder's current section and add text.
builder.PageSetup.Orientation = Orientation.Landscape;
builder.PageSetup.VerticalAlignment = PageVerticalAlignment.Center;
builder.Writeln("This is the first section, which landscape oriented with vertically centered text.");

// If we start a new section using a document builder,
// it will inherit the builder's current page setup properties.
builder.InsertBreak(BreakType.SectionBreakNewPage);

Assert.That(doc.Sections[1].PageSetup.Orientation, Is.EqualTo(Orientation.Landscape));
Assert.That(doc.Sections[1].PageSetup.VerticalAlignment, Is.EqualTo(PageVerticalAlignment.Center));

// We can revert its page setup properties to their default values using the "ClearFormatting" method.
builder.PageSetup.ClearFormatting();

Assert.That(doc.Sections[1].PageSetup.Orientation, Is.EqualTo(Orientation.Portrait));
Assert.That(doc.Sections[1].PageSetup.VerticalAlignment, Is.EqualTo(PageVerticalAlignment.Top));

builder.Writeln("This is the second section, which is in default Letter paper size, portrait orientation and top alignment.");

doc.Save(ArtifactsDir + "PageSetup.ClearFormatting.docx");
```

### See Also

* namespace [Aspose.Words](../../aspose.words/)
* assembly [Aspose.Words](../../)
