Word.PageSetup class
Word 文書またはセクションのページ設定を表します。
- Extends
注釈
使用元
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-section-starts.yaml
await Word.run(async (context) => {
// Configure document-wide page settings for a report that will be printed and bound.
const pageSetup: Word.PageSetup = context.document.pageSetup;
pageSetup.set({
paperSize: Word.PaperSize.letter,
orientation: Word.PageOrientation.portrait,
topMargin: 72,
bottomMargin: 72,
leftMargin: 90,
rightMargin: 72,
gutter: 18,
gutterPosition: Word.GutterPosition.left,
mirrorMargins: true,
oddAndEvenPagesHeaderFooter: true
});
const sections: Word.SectionCollection = context.document.sections;
sections.load("items");
await context.sync();
// Start the main chapter on an odd-numbered page so it appears on the right in a bound document.
const chapterPageSetup: Word.PageSetup = sections.items[1].pageSetup;
chapterPageSetup.sectionStart = Word.SectionStart.oddPage;
chapterPageSetup.differentFirstPageHeaderFooter = true;
// Keep the appendix in a separate section, but let it begin on the current page.
sections.items[2].pageSetup.sectionStart = Word.SectionStart.continuous;
await context.sync();
console.log("Applied print and binding settings to the report.");
});
プロパティ
| book |
Microsoft Word で文書を小冊子として印刷するかどうかを指定します。 |
| book |
各小冊子のページ数を指定します。 |
| book |
Microsoft Word で、双方向またはアジア言語の文書のブック折り印刷の印刷順序を逆にするかどうかを指定します。 |
| bottom |
ページの下端と本文テキストの下端の間の距離 (ポイント単位) を指定します。 |
| chars |
ドキュメント グリッドの 1 行あたりの文字数を指定します。 |
| context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
| different |
最初のページのヘッダーとフッターが異なるかどうかを指定します。 |
| footer |
フッターとページ下部までの距離をポイント単位で指定します。 |
| gutter | 製本のためにドキュメントまたはセクションの各ページに追加される余白スペースの量をポイント単位で指定します。 |
| gutter |
文書内で余白をどちら側に表示するかを指定します。 |
| gutter |
Microsoft Word が右から左の言語と左から右の言語のどちらで、現在の文書に余白を使用するかを指定します。 |
| header |
ヘッダーとページの上部の間の距離をポイント単位で指定します。 |
| layout |
現在のドキュメントのレイアウト モードを指定します。 |
| left |
ページの左端と本文テキストの左端までの距離 (ポイント単位) を指定します。 |
| line |
|
| lines |
ドキュメント グリッドの 1 ページあたりの行数を指定します。 |
| mirror |
見開きページの内側と外側の余白を同じ幅にすることを指定します。 |
| odd |
奇数ページと偶数ページのヘッダーとフッターが異なるかどうかを指定します。 |
| orientation | ページの向きを指定します。 |
| page |
ページの高さをポイント単位で指定します。 |
| page |
ページの幅をポイント単位で指定します。 |
| paper |
ページの用紙サイズを指定します。 |
| right |
ページの右端と本文テキストの右端の間の距離 (ポイント単位) を指定します。 |
| section |
指定したセクションの読み上げ順序と配置を指定します。 |
| section |
指定されたオブジェクトのセクション区切りの種類を指定します。 |
| show |
グリッドを表示するかどうかを指定します。 |
| suppress |
文末脚注を抑制しない次のセクションの最後に文末脚注を印刷するかどうかを指定します。 |
| text |
|
| top |
ページの上余白をポイント単位で指定します。 |
| two |
1 枚に 2 ページ印刷するかどうかを指定します。 |
| vertical |
ドキュメントまたはセクションの各ページのテキストの垂直方向の配置を指定します。 |
メソッド
| load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
| set(properties, options) | オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクト、または同じ型の別の API オブジェクトを渡すことができます。 |
| set(properties) | 既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。 |
| set |
指定されたページ設定を、作業中の文書および現在使用しているテンプレートを使って作成する新規文書の既定値として設定します。 |
| toggle |
文書またはセクションのページの縦横の方向を切り替えます。 |
| toJSON() | API オブジェクトが |
| track() | ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを |
| untrack() | 前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 |
プロパティの詳細
bookFoldPrinting
Microsoft Word で文書を小冊子として印刷するかどうかを指定します。
bookFoldPrinting: boolean;
プロパティ値
boolean
注釈
bookFoldPrintingSheets
bookFoldReversePrinting
Microsoft Word で、双方向またはアジア言語の文書のブック折り印刷の印刷順序を逆にするかどうかを指定します。
bookFoldReversePrinting: boolean;
プロパティ値
boolean
注釈
bottomMargin
ページの下端と本文テキストの下端の間の距離 (ポイント単位) を指定します。
bottomMargin: number;
プロパティ値
number
注釈
charsLine
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
differentFirstPageHeaderFooter
最初のページのヘッダーとフッターが異なるかどうかを指定します。
differentFirstPageHeaderFooter: boolean;
プロパティ値
boolean
注釈
footerDistance
gutter
製本のためにドキュメントまたはセクションの各ページに追加される余白スペースの量をポイント単位で指定します。
gutter: number;
プロパティ値
number
注釈
gutterPosition
文書内で余白をどちら側に表示するかを指定します。
gutterPosition: Word.GutterPosition | "Left" | "Right" | "Top";
プロパティ値
Word.GutterPosition | "Left" | "Right" | "Top"
注釈
gutterStyle
Microsoft Word が右から左の言語と左から右の言語のどちらで、現在の文書に余白を使用するかを指定します。
gutterStyle: Word.GutterStyle | "Bidirectional" | "Latin";
プロパティ値
Word.GutterStyle | "Bidirectional" | "Latin"
注釈
headerDistance
layoutMode
現在のドキュメントのレイアウト モードを指定します。
layoutMode: Word.LayoutMode | "Default" | "Grid" | "LineGrid" | "Genko";
プロパティ値
Word.LayoutMode | "Default" | "Grid" | "LineGrid" | "Genko"
注釈
leftMargin
ページの左端と本文テキストの左端までの距離 (ポイント単位) を指定します。
leftMargin: number;
プロパティ値
number
注釈
lineNumbering
PageSetup オブジェクトの行番号を表すLineNumbering オブジェクトを指定します。
lineNumbering: Word.LineNumbering;
プロパティ値
注釈
linesPage
mirrorMargins
見開きページの内側と外側の余白を同じ幅にすることを指定します。
mirrorMargins: boolean;
プロパティ値
boolean
注釈
oddAndEvenPagesHeaderFooter
奇数ページと偶数ページのヘッダーとフッターが異なるかどうかを指定します。
oddAndEvenPagesHeaderFooter: boolean;
プロパティ値
boolean
注釈
orientation
ページの向きを指定します。
orientation: Word.PageOrientation | "Portrait" | "Landscape";
プロパティ値
Word.PageOrientation | "Portrait" | "Landscape"
注釈
pageHeight
pageWidth
paperSize
ページの用紙サイズを指定します。
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";
プロパティ値
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"
注釈
rightMargin
ページの右端と本文テキストの右端の間の距離 (ポイント単位) を指定します。
rightMargin: number;
プロパティ値
number
注釈
sectionDirection
指定したセクションの読み上げ順序と配置を指定します。
sectionDirection: Word.SectionDirection | "RightToLeft" | "LeftToRight";
プロパティ値
Word.SectionDirection | "RightToLeft" | "LeftToRight"
注釈
sectionStart
指定されたオブジェクトのセクション区切りの種類を指定します。
sectionStart: Word.SectionStart | "Continuous" | "NewColumn" | "NewPage" | "EvenPage" | "OddPage";
プロパティ値
Word.SectionStart | "Continuous" | "NewColumn" | "NewPage" | "EvenPage" | "OddPage"
注釈
showGrid
suppressEndnotes
文末脚注を抑制しない次のセクションの最後に文末脚注を印刷するかどうかを指定します。
suppressEndnotes: boolean;
プロパティ値
boolean
注釈
textColumns
PageSetup オブジェクトのテキスト列のセットを表す TextColumnCollection オブジェクトを取得します。
readonly textColumns: Word.TextColumnCollection;
プロパティ値
注釈
topMargin
twoPagesOnOne
verticalAlignment
ドキュメントまたはセクションの各ページのテキストの垂直方向の配置を指定します。
verticalAlignment: Word.PageSetupVerticalAlignment | "Top" | "Center" | "Justify" | "Bottom";
プロパティ値
Word.PageSetupVerticalAlignment | "Top" | "Center" | "Justify" | "Bottom"
注釈
メソッドの詳細
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(options?: Word.Interfaces.PageSetupLoadOptions): Word.PageSetup;
パラメーター
読み込むオブジェクトのプロパティのオプションを指定します。
返品
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNames?: string | string[]): Word.PageSetup;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切りの文字列または文字列の配列。
返品
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync() を呼び出す必要があります。
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Word.PageSetup;
パラメーター
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select は読み込むプロパティを指定するコンマ区切りの文字列であり、 propertyNamesAndPaths.expand は読み込むナビゲーションのプロパティを指定するコンマ区切りの文字列です。
返品
set(properties, options)
オブジェクトの複数のプロパティを同時に設定します。 適切なプロパティを持つプレーン オブジェクト、または同じ型の別の API オブジェクトを渡すことができます。
set(properties: Interfaces.PageSetupUpdateData, options?: OfficeExtension.UpdateOptions): void;
パラメーター
- properties
- Word.Interfaces.PageSetupUpdateData
メソッドが呼び出されたオブジェクトのプロパティと同型構造のプロパティを持つ JavaScript オブジェクト。
- options
- OfficeExtension.UpdateOptions
プロパティ オブジェクトが読み取り専用プロパティを設定しようとした場合にエラーを抑制するオプションを提供します。
返品
void
set(properties)
既存の読み込まれたオブジェクトに基づいて、オブジェクトに複数のプロパティを同時に設定します。
set(properties: Word.PageSetup): void;
パラメーター
- properties
- Word.PageSetup
返品
void
setAsTemplateDefault()
指定されたページ設定を、作業中の文書および現在使用しているテンプレートを使って作成する新規文書の既定値として設定します。
setAsTemplateDefault(): void;
返品
void
注釈
togglePortrait()
toJSON()
API オブジェクトが JSON.stringify() に渡されるときに、より有用な出力を提供するために、JavaScript toJSON() メソッドをオーバーライドします。 (次に、JSON.stringify渡されたオブジェクトの toJSON メソッドを呼び出します)。元の Word.PageSetup オブジェクトが API オブジェクトであるのに対し、 toJSON メソッドは、元のオブジェクトから読み込まれた子プロパティの浅いコピーを含むプレーンな JavaScript オブジェクト ( Word.Interfaces.PageSetupData と型指定) を返します。
toJSON(): Word.Interfaces.PageSetupData;
返品
例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-section-starts.yaml
await Word.run(async (context) => {
const pageSetup: Word.PageSetup = context.document.pageSetup;
pageSetup.load();
const sections: Word.SectionCollection = context.document.sections;
sections.load("items");
await context.sync();
sections.items.forEach((section) => section.pageSetup.load("sectionStart"));
await context.sync();
console.log("Document page setup:", pageSetup.toJSON());
sections.items.forEach((section, index) => {
console.log(`Section ${index + 1} starts: ${section.pageSetup.sectionStart}`);
});
});
track()
ドキュメントの環境変更に基づいて自動的に調整する目的でオブジェクトを追跡します。 この呼び出しは、 context.trackedObjects.add(thisObject) の短縮形です。 このオブジェクトを .sync 呼び出しと ".run" バッチの連続実行の外部で使用していて、プロパティを設定したり、オブジェクトでメソッドを呼び出したりするときに "InvalidObjectPath" エラーが発生する場合は、オブジェクトが最初に作成されたときに、追跡対象のオブジェクト コレクションにオブジェクトを追加する必要があります。 このオブジェクトがコレクションの一部である場合は、親コレクションも追跡する必要があります。
track(): Word.PageSetup;
返品
untrack()
前に追跡されていた場合、このオブジェクトに関連付けられているメモリを解放します。 この呼び出しは、 context.trackedObjects.remove(thisObject) の省略形です。 追跡対象オブジェクトが多いとホスト アプリケーションの動作が遅くなります。追加したオブジェクトが不要になったら、必ずそれを解放してください。 メモリ リリースを有効にする前に、 context.sync() を呼び出す必要があります。
untrack(): Word.PageSetup;