Zoom

更新时间:
复制 MD 格式

This topic describes the API operations that are related to Zoom objects in Word documents.

ActiveDocument.ActiveWindow.View.Zoom

Returns a Zoom object.

Important

Only IMM WebOffice SDK for JavaScript V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.ActiveWindow.View.Zoom

    expression: an Application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain a Zoom object.
      const Zoom = await app.ActiveDocument.ActiveWindow.View.Zoom;
    }

ActiveDocument.ActiveWindow.View.Zoom.PageFit

Sets whether to zoom the view to fit the size of the window.

  • Syntax

    expression.ActiveDocument.ActiveWindow.View.Zoom.PageFit = Number

    expression: an Application object.

    Valid values of the Number parameter:

    • 0: does not zoom the view to fit the size of the document window after the document window is resized.

    • 2: zooms the view to fit the resized window.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Specify that the view is not zoomed to fit the size of the window.
      app.ActiveDocument.ActiveWindow.View.Zoom.PageFit = 0;
    }

ActiveDocument.ActiveWindow.View.Zoom.Percentage

Sets or returns the zoom percentage for a window.

Important

Only WebOffice for PCs supports a window zoom percentage.

  • Syntax

    expression.ActiveDocument.ActiveWindow.View.Zoom.Percentage

    expression: an Application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain the window zoom percentage. The default zoom percentage is 100%.
      const result = await app.ActiveDocument.ActiveWindow.View.Zoom.Percentage;
      console.log(result); 
    
      // Set the window zoom percentage to 40% after 3,000 ms.
      setTimeout(() => {
        app.ActiveDocument.ActiveWindow.View.Zoom.Percentage = 40;
      }, 3000);
    }