Edit

Share via


Word.PageSetup class

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Represents the page setup settings for a Word document or section.

Extends

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

Properties

bookFoldPrinting

Specifies whether Microsoft Word prints the document as a booklet.

bookFoldPrintingSheets

Specifies the number of pages for each booklet.

bookFoldReversePrinting

Specifies if Microsoft Word reverses the printing order for book fold printing of bidirectional or Asian language documents.

bottomMargin

Specifies the distance (in points) between the bottom edge of the page and the bottom boundary of the body text.

charsLine

Specifies the number of characters per line in the document grid.

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

differentFirstPageHeaderFooter

Specifies whether the first page has a different header and footer.

footerDistance

Specifies the distance between the footer and the bottom of the page in points.

gutter

Specifies the amount (in points) of extra margin space added to each page in a document or section for binding.

gutterPosition

Specifies on which side the gutter appears in a document.

gutterStyle

Specifies whether Microsoft Word uses gutters for the current document based on a right-to-left language or a left-to-right language.

headerDistance

Specifies the distance between the header and the top of the page in points.

layoutMode

Specifies the layout mode for the current document.

leftMargin

Specifies the distance (in points) between the left edge of the page and the left boundary of the body text.

lineNumbering

Specifies a LineNumbering object that represents the line numbers for the PageSetup object.

linesPage

Specifies the number of lines per page in the document grid.

mirrorMargins

Specifies if the inside and outside margins of facing pages are the same width.

oddAndEvenPagesHeaderFooter

Specifies whether odd and even pages have different headers and footers.

orientation

Specifies the orientation of the page.

pageHeight

Specifies the page height in points.

pageWidth

Specifies the page width in points.

paperSize

Specifies the paper size of the page.

rightMargin

Specifies the distance (in points) between the right edge of the page and the right boundary of the body text.

sectionDirection

Specifies the reading order and alignment for the specified sections.

sectionStart

Specifies the type of section break for the specified object.

showGrid

Specifies whether to show the grid.

suppressEndnotes

Specifies if endnotes are printed at the end of the next section that doesn't suppress endnotes.

textColumns

Gets a TextColumnCollection object that represents the set of text columns for the PageSetup object.

topMargin

Specifies the top margin of the page in points.

twoPagesOnOne

Specifies whether to print two pages per sheet.

verticalAlignment

Specifies the vertical alignment of text on each page in a document or section.

Methods

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

set(properties, options)

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

Sets multiple properties on the object at the same time, based on an existing loaded object.

setAsTemplateDefault()

Sets the specified page setup formatting as the default for the active document and all new documents based on the active template.

togglePortrait()

Switches between portrait and landscape page orientations for a document or section.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Word.PageSetup object is an API object, the toJSON method returns a plain JavaScript object (typed as Word.Interfaces.PageSetupData) that contains shallow copies of any loaded child properties from the original object.

track()

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you're using this object across .sync calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you need to add the object to the tracked object collection when the object was first created. If this object is part of a collection, you should also track the parent collection.

untrack()

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You'll need to call context.sync() before the memory release takes effect.

Property Details

bookFoldPrinting

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies whether Microsoft Word prints the document as a booklet.

bookFoldPrinting: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

bookFoldPrintingSheets

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the number of pages for each booklet.

bookFoldPrintingSheets: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

bookFoldReversePrinting

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies if Microsoft Word reverses the printing order for book fold printing of bidirectional or Asian language documents.

bookFoldReversePrinting: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

bottomMargin

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the distance (in points) between the bottom edge of the page and the bottom boundary of the body text.

bottomMargin: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

charsLine

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the number of characters per line in the document grid.

charsLine: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

context

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

differentFirstPageHeaderFooter

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies whether the first page has a different header and footer.

differentFirstPageHeaderFooter: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

footerDistance

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the distance between the footer and the bottom of the page in points.

footerDistance: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

gutter

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the amount (in points) of extra margin space added to each page in a document or section for binding.

gutter: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

gutterPosition

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies on which side the gutter appears in a document.

gutterPosition: Word.GutterPosition | "Left" | "Right" | "Top";

Property Value

Word.GutterPosition | "Left" | "Right" | "Top"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

gutterStyle

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies whether Microsoft Word uses gutters for the current document based on a right-to-left language or a left-to-right language.

gutterStyle: Word.GutterStyle | "Bidirectional" | "Latin";

Property Value

Word.GutterStyle | "Bidirectional" | "Latin"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

headerDistance

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the distance between the header and the top of the page in points.

headerDistance: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

layoutMode

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the layout mode for the current document.

layoutMode: Word.LayoutMode | "Default" | "Grid" | "LineGrid" | "Genko";

Property Value

Word.LayoutMode | "Default" | "Grid" | "LineGrid" | "Genko"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

leftMargin

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the distance (in points) between the left edge of the page and the left boundary of the body text.

leftMargin: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

lineNumbering

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies a LineNumbering object that represents the line numbers for the PageSetup object.

lineNumbering: Word.LineNumbering;

Property Value

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

linesPage

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the number of lines per page in the document grid.

linesPage: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

mirrorMargins

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies if the inside and outside margins of facing pages are the same width.

mirrorMargins: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

oddAndEvenPagesHeaderFooter

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies whether odd and even pages have different headers and footers.

oddAndEvenPagesHeaderFooter: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

orientation

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the orientation of the page.

orientation: Word.PageOrientation | "Portrait" | "Landscape";

Property Value

Word.PageOrientation | "Portrait" | "Landscape"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

pageHeight

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the page height in points.

pageHeight: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

pageWidth

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the page width in points.

pageWidth: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

paperSize

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the paper size of the page.

paperSize: Word.PaperSize | "Size10x14" | "Size11x17" | "Letter" | "LetterSmall" | "Legal" | "Executive" | "A3" | "A4" | "A4Small" | "A5" | "B4" | "B5" | "CSheet" | "DSheet" | "ESheet" | "FanfoldLegalGerman" | "FanfoldStdGerman" | "FanfoldUS" | "Folio" | "Ledger" | "Note" | "Quarto" | "Statement" | "Tabloid" | "Envelope9" | "Envelope10" | "Envelope11" | "Envelope12" | "Envelope14" | "EnvelopeB4" | "EnvelopeB5" | "EnvelopeB6" | "EnvelopeC3" | "EnvelopeC4" | "EnvelopeC5" | "EnvelopeC6" | "EnvelopeC65" | "EnvelopeDL" | "EnvelopeItaly" | "EnvelopeMonarch" | "EnvelopePersonal" | "Custom";

Property Value

Word.PaperSize | "Size10x14" | "Size11x17" | "Letter" | "LetterSmall" | "Legal" | "Executive" | "A3" | "A4" | "A4Small" | "A5" | "B4" | "B5" | "CSheet" | "DSheet" | "ESheet" | "FanfoldLegalGerman" | "FanfoldStdGerman" | "FanfoldUS" | "Folio" | "Ledger" | "Note" | "Quarto" | "Statement" | "Tabloid" | "Envelope9" | "Envelope10" | "Envelope11" | "Envelope12" | "Envelope14" | "EnvelopeB4" | "EnvelopeB5" | "EnvelopeB6" | "EnvelopeC3" | "EnvelopeC4" | "EnvelopeC5" | "EnvelopeC6" | "EnvelopeC65" | "EnvelopeDL" | "EnvelopeItaly" | "EnvelopeMonarch" | "EnvelopePersonal" | "Custom"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

rightMargin

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the distance (in points) between the right edge of the page and the right boundary of the body text.

rightMargin: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

sectionDirection

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the reading order and alignment for the specified sections.

sectionDirection: Word.SectionDirection | "RightToLeft" | "LeftToRight";

Property Value

Word.SectionDirection | "RightToLeft" | "LeftToRight"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

sectionStart

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the type of section break for the specified object.

sectionStart: Word.SectionStart | "Continuous" | "NewColumn" | "NewPage" | "EvenPage" | "OddPage";

Property Value

Word.SectionStart | "Continuous" | "NewColumn" | "NewPage" | "EvenPage" | "OddPage"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

showGrid

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies whether to show the grid.

showGrid: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

suppressEndnotes

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies if endnotes are printed at the end of the next section that doesn't suppress endnotes.

suppressEndnotes: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

textColumns

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Gets a TextColumnCollection object that represents the set of text columns for the PageSetup object.

readonly textColumns: Word.TextColumnCollection;

Property Value

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

topMargin

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the top margin of the page in points.

topMargin: number;

Property Value

number

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

twoPagesOnOne

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies whether to print two pages per sheet.

twoPagesOnOne: boolean;

Property Value

boolean

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

verticalAlignment

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Specifies the vertical alignment of text on each page in a document or section.

verticalAlignment: Word.PageSetupVerticalAlignment | "Top" | "Center" | "Justify" | "Bottom";

Property Value

Word.PageSetupVerticalAlignment | "Top" | "Center" | "Justify" | "Bottom"

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

Method Details

load(options)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Word.Interfaces.PageSetupLoadOptions): Word.PageSetup;

Parameters

options
Word.Interfaces.PageSetupLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Word.PageSetup;

Parameters

propertyNames

string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: {
            select?: string;
            expand?: string;
        }): Word.PageSetup;

Parameters

propertyNamesAndPaths

{ select?: string; expand?: string; }

propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

Returns

set(properties, options)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.PageSetupUpdateData, options?: OfficeExtension.UpdateOptions): void;

Parameters

properties
Word.Interfaces.PageSetupUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

set(properties)

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Word.PageSetup): void;

Parameters

properties
Word.PageSetup

Returns

void

setAsTemplateDefault()

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Sets the specified page setup formatting as the default for the active document and all new documents based on the active template.

setAsTemplateDefault(): void;

Returns

void

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

togglePortrait()

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Switches between portrait and landscape page orientations for a document or section.

togglePortrait(): void;

Returns

void

Remarks

[ API set: WordApi BETA (PREVIEW ONLY) ]

toJSON()

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Word.PageSetup object is an API object, the toJSON method returns a plain JavaScript object (typed as Word.Interfaces.PageSetupData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Word.Interfaces.PageSetupData;

Returns

track()

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you're using this object across .sync calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you need to add the object to the tracked object collection when the object was first created. If this object is part of a collection, you should also track the parent collection.

track(): Word.PageSetup;

Returns

untrack()

Note

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You'll need to call context.sync() before the memory release takes effect.

untrack(): Word.PageSetup;

Returns