Section

Updated at:

This topic describes the APIs for the Section object in Word documents.

Sections

ActiveDocument.Sections

Retrieves all sections in the document.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections

    expression: The application object for the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get all sections.
      const Sections = await app.ActiveDocument.Sections;
    }

Property

ActiveDocument.Sections.Count

Use the Count property to retrieve the total number of sections in the document.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Count

    expression: The application object for the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get all sections.
      const Sections = await app.ActiveDocument.Sections;
    
      // Get the total number of sections in the document.
      const count = await Sections.Count;
      console.log(count);
    
    }

Section

ActiveDocument.Sections.Item(Index)

Retrieves a single section object.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index)

    expression: The application object for the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get a single section object.
      const Section = await app.ActiveDocument.Sections.Item(Index);
    }

Method

ActiveDocument.Sections.Item(Index).PageSetup.TypesetToPage(PageNum)

Word documents use a flow layout. Use the TypesetToPage() method to specify the number of pages to load initially. Additional pages are loaded as you scroll through the document.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).PageSetup.TypesetToPage(PageNum)

    expression: The application object for the document.

  • Parameters

    Property

    Data type

    Required

    Description

    PageNum

    Number

    Yes

    The number of pages to load initially.

  • Example

    //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Page property object.
      const pageSetup = await app.ActiveDocument.Sections.Item(1).PageSetup;
    
      // Typeset to the specified page.
      await pageSetup.TypesetToPage(2);
    }

Properties

ActiveDocument.Sections.Item(Index).PageSetup

Use the PageSetup property to retrieve the page properties of a single section.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).PageSetup

    expression: The application object for the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get the page properties of the first section.
      const Section = await app.ActiveDocument.Sections.Item(1).PageSetup;
    }

ActiveDocument.Sections.Item(Index).PageSetup.PageWidth

Use the PageWidth property to retrieve the page width.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).PageSetup.PageWidth

    expression: The application object for the document.

  • Example

    //@file=base.docx
    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Page property object.
      const PageSetup = await app.ActiveDocument.Sections.Item(1).PageSetup;
    
      // Get the page width.
      const pageWidth = await PageSetup.PageWidth;
      console.log(pageWidth);
    }

ActiveDocument.Sections.Item(Index).WaterMarks

Use the WaterMarks property to retrieve the watermarks of a single section.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks

    expression: The application object for the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get the watermarks of the first section.
      const Section = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    }

HeadersFooters

ActiveDocument.Sections.Item(Index).Headers

Retrieves all headers in a single section object.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).Headers

    expression: The application object for the document.

  • Parameters

    Property

    Data type

    Required

    Description

    Type

    Enum

    Yes

    The type of header to return. For more information, see WdHeaderFooterIndex.

  • Return value

    Returns a HeadersFooters object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get all headers in a single section object.
      const Headers = await app.ActiveDocument.Sections.Item(Index).Headers;
    }

ActiveDocument.Sections.Item(Index).Footers

Retrieves all footers in a single section object.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).Footers

    expression: The application object for the document.

  • Parameters

    Property

    Data type

    Required

    Description

    Type

    Enum

    Yes

    The type of footer to return. For more information, see WdHeaderFooterIndex.

  • Return value

    Returns a HeadersFooters object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Get all footers in a single section object.
      const Headers = await app.ActiveDocument.Sections.Item(Index).Footers;
    }

Properties

ActiveDocument.Sections.Item(Index).Headers.Range

Use the Range property to retrieve the text content within the header of a single section object.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).Headers.Range

    expression: The application object for the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Get the text content within the header of a single section object.
      const Range = await app.ActiveDocument.Sections.Item(1).Headers.Range;
    }

ActiveDocument.Sections.Item(Index).Footers.Range

Use the Range property to retrieve the text content within the footer of a single section object.

Important

This feature is supported in JS-SDK V1.1.10 and later.

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).Footers.Range

    expression: The application object for the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Get the text content within the footer of a single section object.
      const Range = await app.ActiveDocument.Sections.Item(1).Footers.Range;
    }