Scale the document window and view

更新时间:
复制 MD 格式

This topic describes how to obtain or set the scale of a document window and whether to scale the view to fit the document window after it is resized when you use a text document.

Obtain or set the window scale

Obtain or set the window scale.

  • Syntax

    Expression.ActiveDocument.ActiveWindow.View.Zoom.Percentage

    Expression: the document type application object.

  • Example

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

Set autofit for the view

Specify whether to enable autofit for the view to fit the document window after the window is resized.

  • Syntax

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

    Expression: the document type application object.

    Valid values of Number:

    • 0: Does not scale the view to fit the document window after it is resized.

    • 2: Scales the view to fit the document window after it is resized.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Do not scale the view to fit the document window after it is resized.
      app.ActiveDocument.ActiveWindow.View.Zoom.PageFit = 0;
    }