All Products
Search
Document Center

Intelligent Media Management:Shape

Last Updated:Mar 31, 2025

This topic describes the API operations that are related to the Shape object of text documents.

InlineShapes

ActiveDocument.InlineShapes

Obtains all InlineShape objects in a document.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes

    expression: the document type application object.

  • Examples

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects in a document.
      const info = await app.ActiveDocument.InlineShapes;
    }

Method

ActiveDocument.InlineShapes.AddPicture()

You can insert an InlineShape object by using the AddPicture() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.AddPicture({ FileName, LinkToFile, SaveWithDocument, Range })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    FileName

    String

    Yes

    The path and file name of the InlineShape object.

    LinkToFile

    Boolean

    No

    Specifies whether to link the picture to the source file from which it is created. Valid values:

    • true: link the picture to the source file from which it is created.

    • false: make the picture an independent copy of the file. This is the default value.

    SaveWithDocument

    Boolean

    No

    Specifies whether to save the linked picture with the document. Valid values:

    • true

    • false (default value)

    Range

    String

    No

    The position where the picture is placed in the text.

  • Return values

    Returns an InlineShape object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects in a document.
      const inlineShapes = await app.ActiveDocument.InlineShapes;
    
       // Insert an InlineShape object.
      const inlineShape = await inlineShapes.AddPicture({
        FileName: 'example.com/a.jpg',
        LinkToFile: false,
        SaveWithDocument: false,
        Range: {
          start: 1,
          end: 2,
        }
      });
    }

Property

ActiveDocument.InlineShapes.Count

You can obtain the number of InlineShape objects by using the Count property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Count

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects in a document.
      const shapes = await app.ActiveDocument.InlineShapes;
    
      // Obtain the number of InlineShape objects in the document.
      const count = await shapes.Count;
      console.log(count);
    
    }

InlineShape

ActiveDocument.InlineShapes.Item(Index)

Obtains a single InlineShape object.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index)

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const InlineShapes = await app.ActiveDocument.InlineShapes;
    
      // Obtain the first InlineShape object.
      await InlineShapes.Item(1);
    }

Methods

ActiveDocument.InlineShapes.Item(Index).ConvertToShape()

You can convert an inline shape into a free-floating shape by using the ConvertToShape() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).ConvertToShape()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const shapes = await app.ActiveDocument.InlineShapes;
    
      // Insert an InlineShape object.
      await shapes.AddPicture({
        FileName: 'https://example.aliyundoc.com/image_01.png', 
        LinkToFile: false,
        SaveWithDocument: false,
      });
    
      // Obtain the first InlineShape object.
      const shape = await shapes.Item(1);
    
      // Convert an inline shape into a free-floating shape.
      await shape.ConvertToShape();
    }

ActiveDocument.InlineShapes.Item(Index).Delete()

You can delete an InlineShape object by using the Delete() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).Delete()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const shapes = await app.ActiveDocument.InlineShapes;
    
      // Insert an InlineShape object.
      await shapes.AddPicture({
        FileName: 'https://example.aliyundoc.com/image_01.png', 
        LinkToFile: false,
        SaveWithDocument: false,
      });
    
      // Obtain the first InlineShape object.
      const shape = await shapes.Item(1);  
    
      // Delete the InlineShape object.
      await shape.Delete();
    }

ActiveDocument.InlineShapes.Item(Index).Select()

You can select an InlineShape object by using the Select() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).Select()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const shapes = await app.ActiveDocument.InlineShapes;
    
      // Insert an InlineShape object.
      await shapes.AddPicture({
        FileName: 'https://example.aliyundoc.com/image_01.png', 
        LinkToFile: false,
        SaveWithDocument: false,
      });
    
      // Obtain the first InlineShape object.
      const shape = await shapes.Item(1);  
    
      // Select the InlineShape object.
      await shape.Select();
    }

Property

ActiveDocument.InlineShapes.Item(Index).Data

You can obtain the Base64 data of an InlineShape object by using the Data property.

Important

Only JS-SDK V1.1.14 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).Data

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const shapes = await app.ActiveDocument.InlineShapes;
    
      // Insert an InlineShape object.
      await shapes.AddPicture({
        FileName: 'https://example.aliyundoc.com/image_01.png', 
        LinkToFile: false,
        SaveWithDocument: false,
      });
    
      // Obtain the first InlineShape object.
      const shape = await shapes.Item(1);  
    
      // Asynchronously return the Base64 data of the InlineShape object.
      const Data = await shape.Data;
      console.log(Data);
    }

ActiveDocument.InlineShapes.Item(Index).Height

You can specify the height of an InlineShape object by using the Height property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).Height

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const InlineShapes = await app.ActiveDocument.InlineShapes;
    
      // Obtain the first InlineShape object.
      await InlineShapes.Item(1);  
    
       // Specify the height of the InlineShape object.
       shape.Height = 200;
    }

ActiveDocument.InlineShapes.Item(Index).Width

You can specify the width of an InlineShape object by using the Width property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).Width

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const InlineShapes = await app.ActiveDocument.InlineShapes;
    
      // Obtain the first InlineShape object.
      await InlineShapes.Item(1);  
    
       // Specify the width of the InlineShape object.
       shape.Width = 200;
    }

ActiveDocument.InlineShapes.Item(Index).OLEFormat

You can obtain the Object Linking and Embedding (OLE) characteristics for an InlineShape object by using the OLEFormat property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).OLEFormat

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const shapes = await app.ActiveDocument.InlineShapes;
    
      // Insert an InlineShape object.
      await shapes.AddPicture({
        FileName: 'https://example.aliyundoc.com/image_01.png', 
        LinkToFile: false,
        SaveWithDocument: false,
      });
    
      // Obtain the first InlineShape object.
      const shape = await shapes.Item(1);   
    
      // Obtain the OLE characteristics for the InlineShape object.
      const OLEFormat = await shape.OLEFormat;
    }

ActiveDocument.InlineShapes.Item(Index).OriginData

You can check the Base64 data of the source image of an InlineShape object by using the OriginData property.

Important

Only JS-SDK V1.1.14 and later support this feature.

  • Syntax

    expression.ActiveDocument.InlineShapes.Item(Index).OriginData

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all InlineShape objects.
      const shapes = await app.ActiveDocument.InlineShapes;
    
      // Insert an InlineShape object.
      await shapes.AddPicture({
        FileName: 'https://example.aliyundoc.com/image_01.png', 
        LinkToFile: false,
        SaveWithDocument: false,
      });
    
      // Obtain the first InlineShape object.
      const shape = await shapes.Item(1);  
    
      // Asynchronously return the Base64 data of the source image of the InlineShape object.
      const OriginData = await shape.OriginData;
      console.log(OriginData);
    }

shapes

ActiveDocument.Shapes

Obtains all Shape objects in a document.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    }

Method

ActiveDocument.Shapes.AddPicture()

You can insert a Shape object by using the AddPicture() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.AddPicture({ FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    FileName

    String

    Yes

    The path and file name of the picture.

    LinkToFile

    Boolean

    No

    Specifies whether to link the picture to the source file from which it is created. Valid values:

    • true: link the picture to the source file from which it is created.

    • false: make the picture an independent copy of the file. This is the default value.

    SaveWithDocument

    Boolean

    No

    Specifies whether to save the linked picture with the document. Valid values:

    • true

    • false (default value)

    Left

    Number

    No

    The position of the left edge of the new picture relative to the drawing canvas. Unit: points.

    Top

    Number

    No

    The position of the upper edge of the new picture relative to the drawing canvas. Unit: points.

    Width

    Number

    No

    The width of the picture. Unit: points.

    Height

    Number

    No

    The height of the picture. Unit: points.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Insert a Shape object.
      const shape = await shapes.AddPicture({
        FileName: 'https://example.com/image_01.png, // The path and file name of the picture.
        LinkToFile: true,// Link the picture to the source file from which it is created.
        SaveWithDocument: true,// Save the linked picture with the document.
        Left: 10, // The position of the left edge of the new picture relative to the drawing canvas.
        Top: 10, // The position of the upper edge of the new picture relative to the drawing canvas.
        Width: 60, // The width of the picture.
        Height: 120, // The height of the picture.
      });
    }

Property

ActiveDocument.Shapes.Count

You can obtain the number of all Shape objects by using the Count property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Count

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the number of all Shape objects.
      const count = await shapes.Count;
      console.log(count);
    }

shape

ActiveDocument.Shapes.Item()

Obtains a single Shape object.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index)

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Index

    String

    Yes

    The index number of the Shape object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    }

Methods

ActiveDocument.Shapes.Item(Index).ConvertToInlineShape()

You can convert a Shape object into an InlineShape object by using the ConvertToInlineShape() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).ConvertToInlineShape()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Convert a Shape object into an InlineShape object.
      await shape.ConvertToInlineShape();
    }

ActiveDocument.Shapes.Item(Index).Delete()

You can delete a Shape object by using the Delete() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).Delete()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Delete the Shape object.
      await shape.Delete();
    }

ActiveDocument.Shapes.Item(Index).IncrementLeft()

You can move a Shape object horizontally by the specified number of points by using the IncrementLeft() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).IncrementLeft(Increment)

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Increment

    Number

    Yes

    Specifies the distance to move the shape horizontally. Unit: points. Valid values:

    • Positive: move the shape to the right.

    • Negative: move the shape to the left.

    • 0: Do not move the shape.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Move the Shape object 30 points to the right.
      await shape.IncrementLeft(30);
    }

ActiveDocument.Shapes.Item(Index).IncrementTop()

You can move a Shape object vertically by the specified number of points by using the IncrementTop() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).IncrementLeft(Increment)

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Increment

    Number

    Yes

    Specifies the distance to move the shape vertically. Unit: points. Valid values:

    • Positive: move the shape downward.

    • Negative: move the shape upward.

    • 0: Do not move the shape.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Move the Shape object 30 points downward.
      await shape.IncrementTop(30);
    }

ActiveDocument.Shapes.Item(Index).Select()

You can select a Shape object by using the Select() method.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).Select()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Select the Shape object.
      await shape.Select();
    }

ActiveDocument.Shapes.Item(Index).ZOrder()

You can move a Shape object to a position relative to the text in the z-order by using the ZOrder() method.

Important

Only JS-SDK V1.1.15 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).ZOrder({ ZOrderCmd })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    ZOrderCmd

    Enum

    Yes

    Specifies the position to which you want to move the shape in the z-order. For more information, see ZOrderCmd.

  • Parameters

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Specifies the position to which you want to move the shape in the z-order.
      shape.ZOrder(app.Enum.ZOrderCmd.bringInFrontOfText);
    }

Property

ActiveDocument.Shapes.Item(Index).Data

You can obtain the Base64 data of a Shape object by using the Data property.

Important

Only JS-SDK V1.1.14 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).Data

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Obtain the Base64 data of the Shape object.
      const Data = await shape.Data;
      console.log(Data);;
    }

ActiveDocument.Shapes.Item(Index).Height

You can specify the height of a Shape object by using the Height property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).Height

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Specify the height of the Shape object.
      shape.Height = 240;
    }

ActiveDocument.Shapes.Item(Index).Width

You can specify the width of a Shape object by using the Width property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).Width

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Specify the width of the Shape object.
      shape.Width = 200;
    }

ActiveDocument.Shapes.Item(Index).WrapFormat

You can specify how text wraps around a Shape object by using the WrapFormat property.

Important

Only JS-SDK V1.1.15 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).WrapFormat = WdWrapType

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    WdWrapType

    Enum

    Yes

    Specifies how to wrap text around a Shape object. For more information, see WdWrapType.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Wrap text around the shape.
      shape.WrapFormat = app.Enum.WdWrapType.wdWrapSquare;
    }

ActiveDocument.Shapes.Item(Index).OriginData

You can obtain the Base64 data of a Shape object by using the OriginData property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).OriginData

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all Shape objects.
      const shapes = await app.ActiveDocument.Shapes;
    
      // Obtain the first Shape object.
      const shape = await shapes.Item(1);
    
      // Asynchronously return the width of the Shape object.
      const OriginData = await shape.OriginData;
      console.log(OriginData);
    }

OLEFormat

ActiveDocument.Shapes.Item(Index).OLEFormat

Obtains the Object Linking and Embedding (OLE) characteristics for an OLE object.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).OLEFormat

    or expression.ActiveDocument.InlineShapes.Item(Index).OLEFormat

    expression: the document type application object.

  • Examples

    • For Shape objects

      async function example() {
        await instance.ready();
      
        const app = instance.Application;
        
        // Obtain all Shape objects.
        const shapes = await app.ActiveDocument.Shapes;
      
        // Obtain the first Shape object.
        const shape = await shapes.Item(1);
      
        // Obtain the OLE characteristics for the Shape object.
        const OLEFormat = await shape.OLEFormat;
      }
    • For InlineShape objects

      async function example() {
        await instance.ready();
      
        const app = instance.Application;
        
        // Obtain all InlineShape objects.
        const shapes = await app.ActiveDocument.InlineShapes;
      
        // Obtain the first InlineShape object.
        const shape = await shapes.Item(1);  
      
        // Obtain the OLE characteristics for the InlineShape object.
        const OLEFormat = await shape.OLEFormat;
      }

Property

ActiveDocument.Shapes.Item(Index).OLEFormat.ProgID

You can obtain the programmatic identifier (ProgID) of an Object Linking and Embedding (OLE) object by using the ProgID property.

Important

Only JS-SDK V1.1.10 and later support this feature.

  • Syntax

    expression.ActiveDocument.Shapes.Item(Index).OLEFormat.ProgID

    or expression.ActiveDocument.InlineShapes.Item(Index).OLEFormat.ProgID

    expression: the document type application object.

  • Examples

    • For Shape objects

      async function example() {
        await instance.ready();
      
        const app = instance.Application;
        
        // Obtain all Shape objects.
        const shapes = await app.ActiveDocument.Shapes;
      
        // Obtain the first Shape object.
        const shape = await shapes.Item(1);
      
        // Obtain the OLE characteristics for the Shape object.
        const OLEFormat = await shape.OLEFormat;
      
        // Obtain the ProgID of the Shape object.
        const ProgID = OLEFormat.ProgID;
        console.log(ProgID);
      }
    • For InlineShape objects

      async function example() {
        await instance.ready();
      
        const app = instance.Application;
        
        // Obtain all InlineShape objects.
        const shapes = await app.ActiveDocument.InlineShapes;
      
        // Obtain the first InlineShape object.
        const shape = await shapes.Item(1);  
      
        // Obtain the OLE characteristics for the InlineShape object.
        const OLEFormat = await shape.OLEFormat;
      
        // Obtain the ProgID of the InlineShape object.
        const ProgID = OLEFormat.ProgID;
        console.log(ProgID);
      }