Skip to content
本页内容

页面属性(PageSetup)

页面属性对象

属性列表

属性说明
获取页面宽度

方法列表

方法说明
排版到指定页。

PageWidth

获取页面宽度

语法

表达式.ActiveDocument.Sections.Item(Index).PageSetup.PageWidth

表达式:文档类型应用对象

示例

js
//@file=base.docx
async function example() {
  await instance.ready()

  const app = instance.Application

  // 页面属性对象
  const PageSetup = await app.ActiveDocument.Sections.Item(1).PageSetup

  // 获取页面宽度
  const pageWidth = await PageSetup.PageWidth
  console.log(pageWidth)
}

TypesetToPage(PageNum)

排版到指定页。

由于的 Word(文档)是流式排版,所以可以通过 TypesetToPage() 方法来指定首次加载的页数,让用户滚动的时候进一步加载页面数据。

语法

表达式.ActiveDocument.Sections.Item(Index).PageSetup.TypesetToPage(PageNum)

表达式:文档类型应用对象

参数

属性数据类型默认值必填说明
PageNum
Number
指定首次加载的页数

示例

js
//@file=base.docx
async function example() {
  await instance.ready()

  const app = instance.Application

  // 页面属性对象
  const PageSetup = await app.ActiveDocument.Sections.Item(1).PageSetup

  // 排版到指定页
  await PageSetup.TypesetToPage(2)
}