Aspose::Words::PageSetup class

PageSetup class

Represents the page setup properties of a section. To learn more, visit the Working with Sections documentation article.

class PageSetup : public IBorderAttrSource

Methods

MethodDescription
ClearFormatting()Resets page setup to default paper size, margins and orientation.
get_Bidi()Specifies that this section contains bidirectional (complex scripts) text.
get_BorderAlwaysInFront()Specifies where the page border is positioned relative to intersecting texts and objects.
get_BorderAppliesTo()Specifies which pages the page border is printed on.
get_BorderDistanceFrom()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.
get_BorderSurroundsFooter()Specifies whether the page border includes or excludes the footer.
get_BorderSurroundsHeader()Specifies whether the page border includes or excludes the header.
get_Borders()Gets a collection of the page borders.
get_BottomMargin()Returns or sets the distance (in points) between the bottom edge of the page and the bottom boundary of the body text.
get_ChapterPageSeparator()Gets or sets the separator character that appears between the chapter number and the page number.
get_CharactersPerLine()Gets or sets the number of characters per line in the document grid.
get_DifferentFirstPageHeaderFooter()True if a different header or footer is used on the first page.
get_EndnoteOptions()Provides options that control numbering and positioning of endnotes in this section.
get_FirstPageTray()Gets or sets the paper tray (bin) to use for the first page of a section. The value is implementation (printer) specific.
get_FooterDistance()Returns or sets the distance (in points) between the footer and the bottom of the page.
get_FootnoteOptions()Provides options that control numbering and positioning of footnotes in this section.
get_Gutter()Gets or sets the amount of extra space added to the margin for document binding.
get_HeaderDistance()Returns or sets the distance (in points) between the header and the top of the page.
get_HeadingLevelForChapter()Gets or sets the heading level style that is applied to the chapter titles in the document.
get_LayoutMode()Gets or sets the layout mode of this section.
get_LeftMargin()Returns or sets the distance (in points) between the left edge of the page and the left boundary of the body text.
get_LineNumberCountBy()Returns or sets the numeric increment for line numbers.
get_LineNumberDistanceFromText()Gets or sets distance between the right edge of line numbers and the left edge of the document.
get_LineNumberRestartMode()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.
get_LineStartingNumber()Gets or sets the starting line number.
get_LinesPerPage()Gets or sets the number of lines per page in the document grid.
get_Margins()Returns or sets preset Margins of the page.
get_MultiplePages()For multiple page documents, gets or sets how a document is printed or rendered so that it can be bound as a booklet.
get_OddAndEvenPagesHeaderFooter()True if the document has different headers and footers for odd-numbered and even-numbered pages.
get_Orientation()Returns or sets the orientation of the page.
get_OtherPagesTray()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.
get_PageHeight()Returns or sets the height of the page in points.
get_PageNumberStyle()Gets or sets the page number format.
get_PageStartingNumber()Gets or sets the starting page number of the section.
get_PageWidth()Returns or sets the width of the page in points.
get_PaperSize()Returns or sets the paper size.
get_RestartPageNumbering()True if page numbering restarts at the beginning of the section.
get_RightMargin()Returns or sets the distance (in points) between the right edge of the page and the right boundary of the body text.
get_RtlGutter()Gets or sets whether Microsoft Word uses gutters for the section based on a right-to-left language or a left-to-right language.
get_SectionStart()Returns or sets the type of section break for the specified object.
get_SheetsPerBooklet()Returns or sets the number of pages to be included in each booklet.
get_SuppressEndnotes()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.
get_TextColumns()Returns a collection that represents the set of text columns.
get_TextOrientation()Allows to specify TextOrientation for the whole page. Default value is Horizontal
get_TopMargin()Returns or sets the distance (in points) between the top edge of the page and the top boundary of the body text.
get_VerticalAlignment()Returns or sets the vertical alignment of text on each page in a document or section.
set_Bidi(bool)Specifies that this section contains bidirectional (complex scripts) text.
set_BorderAlwaysInFront(bool)Specifies where the page border is positioned relative to intersecting texts and objects.
set_BorderAppliesTo(Aspose::Words::PageBorderAppliesTo)Specifies which pages the page border is printed on.
set_BorderDistanceFrom(Aspose::Words::PageBorderDistanceFrom)Sets a value that indicates whether the specified page border is measured from the edge of the page or from the text it surrounds.
set_BorderSurroundsFooter(bool)Specifies whether the page border includes or excludes the footer.
set_BorderSurroundsHeader(bool)Specifies whether the page border includes or excludes the header.
set_BottomMargin(double)Sets the distance (in points) between the bottom edge of the page and the bottom boundary of the body text.
set_ChapterPageSeparator(Aspose::Words::ChapterPageSeparator)Sets the separator character that appears between the chapter number and the page number.
set_CharactersPerLine(int32_t)Sets the number of characters per line in the document grid.
set_DifferentFirstPageHeaderFooter(bool)True if a different header or footer is used on the first page.
set_FirstPageTray(int32_t)Sets the paper tray (bin) to use for the first page of a section. The value is implementation (printer) specific.
set_FooterDistance(double)Sets the distance (in points) between the footer and the bottom of the page.
set_Gutter(double)Sets the amount of extra space added to the margin for document binding.
set_HeaderDistance(double)Sets the distance (in points) between the header and the top of the page.
set_HeadingLevelForChapter(int32_t)Sets the heading level style that is applied to the chapter titles in the document.
set_LayoutMode(Aspose::Words::SectionLayoutMode)Sets the layout mode of this section.
set_LeftMargin(double)Sets the distance (in points) between the left edge of the page and the left boundary of the body text.
set_LineNumberCountBy(int32_t)Sets the numeric increment for line numbers.
set_LineNumberDistanceFromText(double)Sets distance between the right edge of line numbers and the left edge of the document.
set_LineNumberRestartMode(Aspose::Words::LineNumberRestartMode)Sets the way line numbering runs that is, whether it starts over at the beginning of a new page or section or runs continuously.
set_LineStartingNumber(int32_t)Sets the starting line number.
set_LinesPerPage(int32_t)Sets the number of lines per page in the document grid.
set_Margins(Aspose::Words::Margins)Sets preset Margins of the page.
set_MultiplePages(Aspose::Words::Settings::MultiplePagesType)For multiple page documents, gets or sets how a document is printed or rendered so that it can be bound as a booklet.
set_OddAndEvenPagesHeaderFooter(bool)True if the document has different headers and footers for odd-numbered and even-numbered pages.
set_Orientation(Aspose::Words::Orientation)Sets the orientation of the page.
set_OtherPagesTray(int32_t)Sets the paper tray (bin) to be used for all but the first page of a section. The value is implementation (printer) specific.
set_PageHeight(double)Sets the height of the page in points.
set_PageNumberStyle(Aspose::Words::NumberStyle)Sets the page number format.
set_PageStartingNumber(int32_t)Sets the starting page number of the section.
set_PageWidth(double)Sets the width of the page in points.
set_PaperSize(Aspose::Words::PaperSize)Sets the paper size.
set_RestartPageNumbering(bool)True if page numbering restarts at the beginning of the section.
set_RightMargin(double)Sets the distance (in points) between the right edge of the page and the right boundary of the body text.
set_RtlGutter(bool)Sets whether Microsoft Word uses gutters for the section based on a right-to-left language or a left-to-right language.
set_SectionStart(Aspose::Words::SectionStart)Sets the type of section break for the specified object.
set_SheetsPerBooklet(int32_t)Sets the number of pages to be included in each booklet.
set_SuppressEndnotes(bool)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.
set_TextOrientation(Aspose::Words::TextOrientation)Allows to specify TextOrientation for the whole page. Default value is Horizontal
set_TopMargin(double)Sets the distance (in points) between the top edge of the page and the top boundary of the body text.
set_VerticalAlignment(Aspose::Words::PageVerticalAlignment)Sets the vertical alignment of text on each page in a document or section.

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.

auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);

// Modify the page setup properties for the builder's current section and add text.
builder->get_PageSetup()->set_Orientation(Orientation::Landscape);
builder->get_PageSetup()->set_VerticalAlignment(PageVerticalAlignment::Center);
builder->Writeln(u"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_EQ(doc->get_Sections()->idx_get(1)->get_PageSetup()->get_Orientation(), Orientation::Landscape);
ASSERT_EQ(doc->get_Sections()->idx_get(1)->get_PageSetup()->get_VerticalAlignment(), PageVerticalAlignment::Center);

// We can revert its page setup properties to their default values using the "ClearFormatting" method.
builder->get_PageSetup()->ClearFormatting();

ASSERT_EQ(doc->get_Sections()->idx_get(1)->get_PageSetup()->get_Orientation(), Orientation::Portrait);
ASSERT_EQ(doc->get_Sections()->idx_get(1)->get_PageSetup()->get_VerticalAlignment(), PageVerticalAlignment::Top);

builder->Writeln(u"This is the second section, which is in default Letter paper size, portrait orientation and top alignment.");

doc->Save(get_ArtifactsDir() + u"PageSetup.ClearFormatting.docx");

See Also