All Products
Search
Document Center

Intelligent Media Management:AnnoAPI

Last Updated:Oct 29, 2024

This topic describes the API operations related to AnnoAPI objects of PDF documents.

AnnoAPI

Obtains the current AnnoAPI object.

  • Syntax

    expression.ActivePDF.AnnoAPI

    expression: an Application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      // Obtain the current AnnoAPI object.
      const AnnoAPI = await app.ActivePDF.AnnoAPI;
    }
    

Methods

AnnoAPI.SelectAnno()

Selects the specified annotation.

Important

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

  • Syntax

    expression.AnnoAPI.SelectAnno({PageIndex, Id})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    PageIndex

    Number

    Yes

    The page number of the page on which the annotation resides. Page numbers start from 1.

    ID

    String

    Yes

    The annotation ID.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Select the specified annotation.
      await app.ActivePDF.AnnoAPI.SelectAnno({PageIndex:1, Id: '{8c3300cf-ec08-4350-aab3-2f42c480d92e}'});
    }
    

AnnoAPI.ClearAnnoSelection()

Deselects an annotation.

Important

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

  • Syntax

    expression.AnnoAPI.ClearAnnoSelection()

    expression: an Application object.

  • Example

    async function example() {
      await instance.ready();
      const app = instance.Application;
      // Deselect the specified annotation.
      await app.ActivePDF.AnnoAPI.ClearAnnoSelection();
    }
    

AnnoAPI.GetAnnoSelection()

Obtains annotations in the selection.

Important

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

  • Syntax

    expression.AnnoAPI.GetAnnoSelection()

    expression: an Application object.

  • Return values

    Parameter

    Type

    Description

    result

    Array

    The array that contains information about the annotations returned.

  • Description of result

    Parameter

    Type

    Description

    type

    String

    The annotation type.

    id

    String

    The annotation ID.

    pageIndex

    Number

    The page number of the page on which the annotation resides. Page numbers start from 0.

    rect

    Object

    The position information of the annotation.

  • Example

    async function example() {
      await instance.ready();
      const app = instance.Application;
      // Obtain annotations in the selection.
      await app.ActivePDF.AnnoAPI.GetAnnoSelection();
    }
    

AnnoAPI.CopyAnnoSelection()

Copies annotations in the selection

Important

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

  • Syntax

    expression.AnnoAPI.CopyAnnoSelection()

    expression: an Application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Copy annotations in the selection.
      await app.ActivePDF.AnnoAPI.CopyAnnoSelection();
    
    }

AnnoAPI.SetSelectionAnno()

Sets the selection as an annotation (highlight, underline, or strikeout).

Important

JS-SDK V1.1.19 and later support this feature. This feature is supported only on PCs.

  • Syntax

    expression.AnnoAPI.SetSelectionAnno({type, color})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    type

    Enum

    Yes

    The annotation type. For more information, see Enum.AnnoType.

    color

    String

    No

    The RGB or RGBA color.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Highlight the selection.
      await app.ActivePDF.AnnoAPI.SetSelectionAnno({type: app.Enum.AnnoType.Highlight, color: 'rgba(14,14,14,1)'});
    
    }

AnnoAPI.SetAnnoMode()

Sets the annotation mode (highlight, underline, or strikeout).

Important

JS-SDK V1.1.19 and later support this feature. This feature is supported only on PCs.

  • Syntax

    expression.AnnoAPI.SetAnnoMode({type, color})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    type

    Enum

    Yes

    The annotation type. For more information, see Enum.AnnoType.

    color

    String

    No

    The RGB or RGBA color.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Set the highlight mode.
      await app.ActivePDF.AnnoAPI.SetAnnoMode({type: app.Enum.AnnoType.Highlight, color: 'rgba(14,14,14,1)'});
    
    }

AnnoAPI.ExitAnnoMode()

Exists the annotation mode (highlight, underline, or strikeout).

Important

JS-SDK V1.1.19 and later support this feature. This feature is supported only on PCs.

  • Syntax

    expression.AnnoAPI.ExitAnnoMode()

    expression: an Application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Exit the annotation mode.
      await app.ActivePDF.AnnoAPI.ExitAnnoMode();
    
    }

AnnoAPI.SwitchEraser()

Enters or exits the eraser mode.

Important

JS-SDK V1.1.19 and later support this feature. This feature is supported only on PCs.

  • Syntax

    expression.AnnoAPI.SwitchEraser({IsEraser})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    IsEraser

    Boolean

    No

    Sets the eraser mode. To enter the eraser mode, set this parameter to true. To exist the eraser mode, set this parameter to false.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Enter the eraser mode.
      await app.ActivePDF.AnnoAPI.SwitchEraser({IsEraser: true});
    
      // Exit the eraser mode.
      await app.ActivePDF.AnnoAPI.SwitchEraser({IsEraser: false});
    
    }

AnnoAPI.AddTextAnnoComment()

Adds a comment on an annotation.

Important

JS-SDK V1.1.19 and later support this feature. This feature is supported only on PCs.

  • Syntax

    expression.AnnoAPI.AddTextAnnoComment({PageIndex, Id, Comment})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    PageIndex

    Number

    Yes

    The page number of the page on which the comment resides. Page numbers start from 1.

    Id

    String

    Yes

    The annotation ID.

    Comment

    String

    Yes

    The comment.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Add a comment on an annotation.
      await app.ActivePDF.AnnoAPI.AddTextAnnoComment({PageIndex: 1, Id: '{8c3300cf-ec08-4350-aab3-2f42c480d92e}', Comment: '11111'});
    
    }

AnnoAPI.SetAnnoStyleBySelection()

Sets an annotation style for a selection.

  • Syntax

    expression.AnnoAPI.SetAnnoStyleBySelection({Style})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    Style

    Enum

    Yes

    The bubble style. For more information, see Enum.TextStyle.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Set the bubble style to the circle.
      await app.ActivePDF.AnnoAPI.SetAnnoStyleBySelection({Style: app.Enum.TextStyle.Comment});
    
    }

AnnoAPI.SetAnnoLineWidthBySelection()

Sets the stroke width. This setting takes for marker pens and smart brushes.

  • Syntax

    expression.AnnoAPI.SetAnnoLineWidthBySelection({Width})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    Width

    Number

    Yes

    The stroke width. The value range is 1 to 12.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Set the stroke width to 10.
      await app.ActivePDF.AnnoAPI.SetAnnoLineWidthBySelection({Width: 10});
    
    }

AnnoAPI.SetAnnoColorBySelection()

Sets the color for annotations. This setting takes for marker pens and smart brushes.

  • Syntax

    expression.AnnoAPI.SetAnnoColorBySelection({Color})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    Color

    String

    Yes

    The RGB or RGBA color.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Set the color for annotations in the selection.
      await app.ActivePDF.AnnoAPI.SetAnnoColorBySelection({Color: 'rgba(14,14,14,1)'});
    
    }

AnnoAPI.SetInkMode()

Sets the ink mode.

Important

JS-SDK V1.1.19 and later support this feature. This feature is supported only on PCs.

  • Syntax

    expression.AnnoAPI.SetInkMode({type, lineWidth, color})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    type

    Enum

    Yes

    The ink type.

    lineWidth

    Number

    No

    The stroke width. The value range is 0.5 to 12.

    Color

    String

    No

    The color.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Use the pen with a stroke width of 6 and set the color to rgba(189,16,224,1).
      await app.ActivePDF.AnnoAPI.SetInkMode({type: app.Enum.InkType.Handwriting, lineWidth: 6,color:'rgba(189,16,224,1)'});
    
    }

AnnoAPI.ExitInkMode()

Exits the ink mode.

Important

JS-SDK V1.1.19 and later support this feature. This feature is supported only on PCs.

  • Syntax

    expression.AnnoAPI.ExitInkMode()

    expression: an Application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Exit the ink mode.
      await app.ActivePDF.AnnoAPI.ExitInkMode();
    
    }

AnnoAPI.AddTextData()

Adds an annotation bubble.

Important

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

  • Syntax

    expression.AnnoAPI.AddTextData({x, y, content, color, style})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    x

    Number

    Yes

    The x-coordinate (clientX).

    y

    Number

    Yes

    The y-coordinate (clientY).

    content

    String

    Yes

    The content text.

    color

    No

    The RGBA color.

    Style

    Enum

    No

    The bubble style. For more information, see Enum.TextStyle.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Add an annotation bubble.
      await app.ActivePDF.AnnoAPI.AddTextData({x: 600, y: 400, content: '11111', color: 'rgba(14,14,14,1)', style: app.Enum.TextStyle.Comment});
    
    }

AnnoAPI.InsertAnnoPic()

Adds an image annotation.

Important

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

  • Syntax

    expression.AnnoAPI.InsertAnnoPic({dataUrl, width, height, x, y})

    expression: an Application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    dataUrl

    String

    Yes

    The Base64-encoded image URL.

    width

    Number

    Yes

    The image width.

    height

    Number

    Yes

    The image height.

    x

    Number

    Yes

    The x-coordinate (clientX).

    y

    Number

    Yes

    The y-coordinate (clientY).

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      const dataUrl = 'base64'; // Provide the Base64-encoded string.
      
      // Add the image annotation.
      await app.ActivePDF.AnnoAPI.InsertAnnoPic({dataUrl: dataUrl, width: 543, height: 277, x: 600, y: 400}); 
    
    }