AnnoAPI

更新时间:
复制 MD 格式

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

AnnoAPI

The current AnnoAPI instance

  • 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()

The SelectAnno() method selects annotations.

Important

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

  • Syntax

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

    expression: an Application object.

  • Parameters

    Property

    Type

    Required

    Description

    PageIndex

    Number

    Yes

    The page number where the annotation is located. 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()

You can use the ClearAnnoSelection() method to cancel the selection.

Important

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

  • Syntax

    expression.AnnoAPI.ClearAnnoSelection()

    Expression: Application Object for Document Type

  • Example

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

AnnoAPI.GetAnnoSelection()

You can use the GetAnnoSelection() method to retrieve the selected annotations.

Important

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

  • Syntax

    expression.AnnoAPI.GetAnnoSelection()

    Expression: Application object for a document type

  • Return values

    Parameter

    Data type

    Description

    result

    Array

    The array that contains information about the annotations returned.

  • The Object annotation in the result structure

    Parameter

    Data 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()

You can retrieve the selected annotation using the CopyAnnoSelection() method.

Important

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

  • Syntax

    expression.AnnoAPI.CopyAnnoSelection()

    Expression: Document-type 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()

You can use the SetSelectionAnno() method to apply an annotation (such as a highlight, strikethrough, or underline) to the selection.

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: Document-Type Application Object

  • Parameters

    Property

    Data Type

    Required

    Description

    type

    Enum

    Yes

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

    color

    String

    No

    RGB or RGBA format

  • 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()

You can use the SetAnnoMode() method to set the annotation mode, such as highlight, strikethrough, or underline.

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: Application object of a document type

  • Parameters

    Parameter

    Data type

    Required

    Description

    type

    Enum

    Yes

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

    color

    String

    No

    RGB or RGBA format

  • 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()

You can exit annotation mode (highlight, strikethrough, and underline) by calling the ExitAnnoMode() method.

Important

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

  • Syntax

    Expression.AnnoAPI.ExitAnnoMode()

    Expression: Document Type and Application Object

  • Example

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

AnnoAPI.SwitchEraser()

You can call the SwitchEraser() method to enable or disable 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

    Property

    Data 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()

You can use the AddTextAnnoComment() method to add a comment to 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: Application object of a document type

  • Parameters

    Property

    Data 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()

The SetAnnoStyleBySelection() method sets the style of a selected annotation.

  • Syntax

    expression.AnnoAPI.SetAnnoStyleBySelection({Style})

    expression: an Application object.

  • Parameters

    Parameter

    Data 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()

The SetAnnoLineWidthBySelection() method sets the line width of a selected annotation for brushes, such as watercolor and smart brushes.

  • Syntax

    expression.AnnoAPI.SetAnnoLineWidthBySelection({Width})

    Expression: Document-Type Application Object

  • Parameters

    Property

    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()

You can use the SetAnnoColorBySelection() method to set the line width of selected annotations for brush tools, such as the watercolor brush and smart brush.

  • Syntax

    expression.AnnoAPI.SetAnnoColorBySelection({Color})

    Expression: Application Object of Document Type

  • Parameters

    Parameter

    Data type

    Required

    Description

    Color

    String

    Yes

    RGB or RGBA format

  • 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()

You can set the brush pattern using the SetInkMode() method.

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: Document Type application object

  • Parameters

    Property

    Data Type

    Required

    Description

    type

    Enum

    Yes

    Brush type

    lineWidth

    Number

    No

    The stroke width. The value must be in the range of 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()

Call the ExitInkMode() method to exit 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: Document-Type Application Object

  • Example

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

AnnoAPI.AddTextData()

You can use the AddTextData() method to add text annotations.

Important

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

  • Syntax

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

    Expression: Application object of a document type

  • Parameters

    Property

    Data type

    Required

    Description

    x

    Number

    Yes

    The x-coordinate (clientX).

    y

    Number

    Yes

    The y-coordinate (clientY).

    content

    String

    Yes

    The content text.

    color

    String

    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()

You can use the InsertAnnoPic() method to insert a stamp 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

    Base64 string of the image

    width

    Number

    Yes

    Width

    height

    Number

    Yes

    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}); 
    
    }