Slides

更新时间:
复制 MD 格式

This topic describes the advanced operations for presentation documents. You can use these operations to obtain the slide objects, run or exit a full-screen slide show, manage animations, configure the slide show settings, monitor the slide show status, turn on or off the slide show thumbnail, and insert a new slide.

Obtain slide objects

  • Syntax

    Expression.ActivePresentation.Slides

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the presentation object.
      const presentation = await app.ActivePresentation;
    
      // Obtain the slide objects.
      const view = await presentation.Slides;
    }

Full-screen slide show

Run a full-screen slide show

Run a slide show of the specified presentation document.

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.Run()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the slide show settings object.
      const SlideShowSettings = await app.ActivePresentation.SlideShowSettings;
    
      // Run a full-screen slide show.
      await SlideShowSettings.Run();
    }

Listen to the full-screen slide show begin events

Listen to the full-screen slide show begin events.

  • Syntax

    Expression.Sub.SlideShowBegin = Function

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Listen to the full-screen slide show begin events.
      app.Sub.SlideShowBegin = async () => {
        console.log ('Begin');
      };
    
      setTimeout( async () => {
        // Run a full-screen slide show.
        await app.ActivePresentation.SlideShowSettings.Run();
      }, 2000);
    }

Exit the full-screen slide show

Exit the full-screen slide show of a specified presentation document.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.Exit()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Exit the full-screen slide show.
      setTimeout( async () => {
        await app.ActivePresentation.SlideShowWindow.View.Exit();
      }, 5000);
    }

Listen to the full-screen slide show end events

Listen to the full-screen slide show end events.

  • Syntax

    Expression.Sub.SlideShowEnd = Function

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Listen to the full-screen slide show end events.
      app.Sub.SlideShowEnd = async () => {
        console.log ('End',);
      };
    
      // End the full-screen slide show after 3,000 milliseconds.
      setTimeout( async () => {
        await app.ActivePresentation.SlideShowWindow.View.Exit();
      }, 3000);
    }

Animations

Obtain the number of animations

Obtain the number of animations on the current slide.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.GetClickCount()

    Expression: the document type application object.

  • Return value

    Returns a number that represents the number of animations on the current slide.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Obtain the number of animations on the current slide.
      const clickCount = await app.ActivePresentation.SlideShowWindow.View.GetClickCount();
      console.log(clickCount);
    }

Obtain the index number of the current mouse click for an animation

Obtain the index number of the current mouse click for an animation that is actively playing on a slide or has just finished.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.GetClickIndex()

    Expression: the document type application object.

  • Return value

    Returns a number that represents the index number of the current mouse click for an animation.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Obtain the index number of the current mouse click for an animation.
      const clickCount = await app.ActivePresentation.SlideShowWindow.View.GetClickIndex();
      console.log(clickCount);
    }

Go to the next animation

Go to the next animation.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.GotoNextClick()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Go to the next animation.
      setTimeout( async () => {
        await app.ActivePresentation.SlideShowWindow.View.GotoNextClick();
      }, 2000);
    }

Listen to the next animation events

Listen to the next animation events.

  • Syntax

    Expression.Sub.SlideShowOnNext = Function

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Listen to the next animation events.
      app.Sub.SlideShowOnNext = async () => {
        console.log ('Next');
      };
    
      // Go to the next animation after 3,000 milliseconds.
      setTimeout( async () => {
        await app.ActivePresentation.SlideShowWindow.View.GotoNextClick();
      }, 3000);
    }

Go to the previous animation

Go to the previous animation

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.GotoPreClick()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Go to the previous animation.
      setTimeout( async () => {
        await app.ActivePresentation.SlideShowWindow.View.GotoPreClick();
      }, 2000);
    }

Listen to the previous animation events

Listen to the previous animation events.

  • Syntax

    Expression.Sub.SlideShowOnPrevious = Function

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Run a full-screen slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
    
      // Listen to the previous animation events.
      app.Sub.SlideShowOnPrevious = async () => {
        console.log ('Previous');
      };
    
      // Go to the next animation after 3,000 milliseconds.
      setTimeout( async () => {
        await app.ActivePresentation.SlideShowWindow.View.GotoNextClick();
      }, 3000);
    
      // Return to the previous step after 5,000 milliseconds.
      setTimeout( async () => {
        await app.ActivePresentation.SlideShowWindow.View.GotoPreClick();
      }, 5000);
    }

Slide show settings

Important

JS-SDK V1.1.15 and later support these features.

Show or hide the page numbers on PCs

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.ShowPage

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the window object.
      const SlideShowWindow = await app.ActivePresentation.SlideShowWindow;
    
      // Obtain the view object.
      const view = await SlideShowWindow.View;
    
      // Show the page numbers in the slide show mode.
      view.ShowPage = true;
    }

Show or hide the toolbar

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.ShowPlayToolbar

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Hide the toolbar.
      app.ActivePresentation.SlideShowSettings.ShowPlayToolbar = false;
    }

Modify the style of the toolbar

Important

To avoid performance impact on the toolbar caused by complex customizations, we recommend that you configure the style of the toolbar by using basic parameters such as top, left, right, bottom and translate.

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.SetPlayToolbarPosition({ Style })

    Expression: the document type application object.

  • Parameters

    Pass in a value of the boolean type to set the style of the toolbar.

    Parameter

    Type

    Required

    Description

    Style

    Object

    Yes

    The style of the toolbar.

    Description of the style parameter

    Field

    Type

    Description

    Show

    Object

    The style of the toolbar when it is displayed. The format of the input parameters is similar to { left: '100px' }.

    Hidden

    Object

    The style of the toolbar when it is hidden.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the slide show settings object.
      const SlideShowSettings = await app.ActivePresentation.SlideShowSettings;
    
      // Run a slide show.
      await SlideShowSettings.Run();
    
      // Modify the style of the toolbar.
      await SlideShowSettings.SetPlayToolbarPosition({
        Style: {
          Show: { top: '10px' }, // The style of the toolbar when it is displayed.
          Hidden: { top: '-100px' }, // The style of the toolbar when it is hidden.
        },
      });
    }

Modify the style of the marker

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.SetPlayInkPosition({ Style })

    Expression: the document type application object.

  • Parameter

    Pass in a value of the boolean type to set the style of the marker.

    Parameter

    Type

    Required

    Description

    Style

    Object

    Yes

    The style of the marker. The format of the input parameters is similar to { left: '100px' }.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the slide show settings object.
      const SlideShowSettings = await app.ActivePresentation.SlideShowSettings;
    
      // Run a slide show.
      await SlideShowSettings.Run();
    
      // Modify the style of the marker.
      await SlideShowSettings.SetPlayInkPosition({
        Style: { background: 'deepskyblue' }, // The style of the marker.
      });
    }

Enable or disable the marker

  • Syntax

    Expression. ActivePresentation.SetOpenMarkerInkEdit({ Open })

    Expression: the document type application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    Open

    Boolean

    No

    Specifies whether to enable the marker.

    • true: enables the marker. This is the default value.

    • false: saves and disables the marker.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Enable the marker.
      await app.ActivePresentation.SetOpenMarkerInkEdit(true);
    
      setTimeout(async () => {
        // Save and disable the marker.
        await app.ActivePresentation.SetOpenMarkerInkEdit(false);
      }, 5000);
    }

Open the remark view

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.OpenRemarkSpeaker()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the slide show settings object.
      const SlideShowSettings = await app.ActivePresentation.SlideShowSettings;
    
      // Run a slide show.
      await SlideShowSettings.Run();
    
      // Open the remark view.
      await SlideShowSettings.OpenRemarkSpeaker();
    }

Enable the countdown

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.SetCountDown()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the slide show settings object.
      const SlideShowSettings = await app.ActivePresentation.SlideShowSettings;
    
      // Run a slide show.
      await SlideShowSettings.Run();
    
      // Enable the countdown.
      await SlideShowSettings.SetCountDown();
    }

Enable autoplay

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.StartAutoPlay()

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the slide show settings object.
      const SlideShowSettings = await app.ActivePresentation.SlideShowSettings;
    
      // Run a slide show.
      await SlideShowSettings.Run();
    
      // Enable autoplay.
      await SlideShowSettings.StartAutoPlay();
    }

Obtain the status of a presentation document

Obtain the status of a presentation document.

  • Syntax

    Expression.ActivePresentation.SlideShowWindow.View.State

    Expression: the document type application object.

  • Return value

    Parameter

    Type

    Description

    state

    String

    The status of the presentation document.

    • edit: in the edit mode.

    • play: in a slide show.

    • masterView: in the master view.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the status.
      const getState = () => {
        return app.ActivePresentation.SlideShowWindow.View.State;
      };
    
      // Obtain the status of the presentation document.
      let currentState = await getState();
      console.log(currentState); // 'edit'
    
      // Run a slide show.
      await app.ActivePresentation.SlideShowSettings.Run();
      currentState = await getState();
      console.log(currentState); // 'play'
    }

Turn on or off the thumbnails

  • Syntax

    Expression.ActivePresentation.SlideShowSettings.SetMiniThumbnailVisible()

    Expression: the document type application object.

  • Parameter

    Pass in a value of the boolean type to turn on or off the thumbnails.

    Parameter

    Type

    Required

    Description

    Visible

    Boolean

    Yes

    Specifies whether to turn on the thumbnails.

    • false: turns off the thumbnails. This is the default value.

    • true: turns on the thumbnails.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Turn on the thumbnails.
      await app.ActivePresentation.SlideShowSettings.SetMiniThumbnailVisible(true);
    }

Insert a new slide

  • Syntax

    Expression.ActivePresentation.Slides.AddSlide()

    Expression: the document type application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    Index

    number

    No

    The location where the new slide is inserted. If the value of this parameter is empty or a negative number, the slide is inserted after the current slide.

    CustomLayout

    object

    No

    The type of the local layout to be used for the new slide. By default, a blank slide is inserted.

    LayoutUrl

    string

    No

    The URL to an online presentation document. If this parameter is specified, the value of layoutType is ignored. The layout in the online presentation document is used. A promise object is returned to notify the result.

    LayoutIndex

    number

    No

    The index of the layout in the online presentation document to be used for the new slide. This parameter must be used with layoutUrl. Otherwise, this parameter is invalid.