WaterMark

更新时间:
复制 MD 格式

This topic describes the API operations that are related to the WaterMark object.

WaterMarks

ActiveDocument.Sections.Item(Index).WaterMarks

Obtains all watermarks from a single Section object.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Index

    Number

    Yes

    The index number of a section that represents a selection, range, or part of the document.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    }

Methods

ActiveDocument.Sections.Item(Index).WaterMarks.AddTemplateWaterMark()

You can insert a template watermark by using the AddTemplateWaterMark() method.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.AddTemplateWaterMark({ Index, ApplyTo })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Index

    Number

    Yes

    The index number of the template watermark that you want to use.

    ApplyTo

    Number

    No

    The position in which you want to insert the watermark. Valid values:

    • 0: the current section.

    • 1: the entire document. This is the default value.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Insert the second template watermark into the entire document.
      waterMarks.AddTemplateWaterMark({
        Index: 2,
        ApplyTo: 1,
      });
    }

ActiveDocument.Sections.Item(Index).WaterMarks.AddTextWaterMark()

You can insert a text watermark by using the AddTextWaterMark() method.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.AddTextWaterMark({ Text, FontName, FontSize, FontColor, Transparency, Gradient })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Text

    String

    Yes

    The text of the watermark.

    FontName

    String

    Yes

    The font of the text.

    FontSize

    Number

    Yes

    The size of the text.

    FontColor

    String

    Yes

    The color of the text. Default value: 0xC0C0C0.

    Transparency

    Number

    Yes

    The transparency of the watermark. Valid values: 0 to 1. The value 0 indicates that the watermark is fully transparency, and the value 1 indicates that the watermark is completely opaque.

    Gradient

    Boolean

    Yes

    The gradient of the watermark. Valid values:

    • false (default value)

    • true

    ApplyTo

    Number

    Yes

    The position where you want to insert the watermark. Valid values:

    • 0: the current section.

    • 1: the entire document. This is the default value.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Insert text watermarks into the entire document.
      await waterMarks.AddTextWaterMark({
        Text: 'Watermark text', // The text of the watermark.
        FontName: 'Song type', // The font of the text.
        FontSize: 40, // The size of the text.
        FontColor: '#171717', // The color of the text.
        Transparency: 0.3, // Transparency.
        Gradient: false, // Gradient.
        ApplyTo: 1, // The insertion position.
      });
    }

ActiveDocument.Sections.Item(Index).WaterMarks.DeleteWaterMark()

You can delete a watermark by using the DeleteWaterMark() method.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.DeleteWaterMark()

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Remove a watermark.
      waterMarks.DeleteWaterMark();
    }

ActiveDocument.Sections.Item(Index).WaterMarks.EditTextWaterMark()

You can modify a watermark by using the EditTextWaterMark() method.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.EditTextWaterMark({ Text, FontName, FontSize, FontColor, Transparency, Gradient })

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Text

    String

    Yes

    The text of the watermark.

    FontName

    String

    Yes

    The font of the text.

    FontSize

    Number

    Yes

    The size of the text.

    FontColor

    String

    Yes

    The color of the text. Default value: 0xC0C0C0.

    Transparency

    Number

    Yes

    The transparency of the watermark.

    Gradient

    Boolean

    Yes

    The gradient of the watermark. Valid values:

    • false (default value)

    • true

    ApplyTo

    Number

    Yes

    The position where you want to insert the watermark. Valid values:

    • 0: the current section.

    • 1: the entire document. This is the default value.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Modify the watermark.
      await waterMarks.EditTextWaterMark({
        Text: 'Watermark text', // The text of the watermark.
        FontName: 'Song type', // The font of the text.
        FontSize: 66, // The size of the text.
        FontColor: '#f00', // The color of the text.
        Transparency: 1, // Transparency.
        Gradient: true, // Gradient.
        ApplyTo: 1, // The insertion position.
      });
    }

WaterMark

ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index)

Obtains a WaterMark object from a Section object.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index)

    expression: the document type application object.

  • Parameters

    Property

    Type

    Required

    Description

    Index

    Number

    Yes

    The index number of the WaterMark object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Obtain a single WaterMark object.
      const waterMark = await waterMarks.Item(1);
    }

Properties

ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).FontColor

You can specify the font color of the watermark by using the FontColor property.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).FontColor

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Obtain a single WaterMark object.
      const waterMark = await waterMarks.Item(1);
    
      // Specify the font color of the watermark.
      waterMark.FontColor = '#fff000';
    }

ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).FontName

You can specify the font of a watermark by using the FontName property.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).FontName

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Obtain a single WaterMark object.
      const waterMark = await waterMarks.Item(1);
    
      // Specify the font of the watermark.
      waterMark.FontName ='Kai type';
    }

ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).FontSize

You can specify the font size of a watermark by using the FontSize property.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).FontSize

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Obtain a single WaterMark object.
      const waterMark = await waterMarks.Item(1);
    
      // Specify the font size of the watermark.
      waterMark.FontSize = 80;
    }

ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).Gradient

You can specify the gradient of a watermark by using the Gradient property.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).Gradient

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Obtain a single WaterMark object.
      const waterMark = await waterMarks.Item(1);
    
      // Specify the gradient of a watermark.
      waterMark.Gradient = true;
    }

ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).Text

You can specify the text of a watermark by using the Text property.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).Text

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Obtain a single WaterMark object.
      const waterMark = await waterMarks.Item(1);
    
      // Specify the text of the watermark.
      waterMark.Text = 'Aliyun';
    }

ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).Transparency

You can specify the transparency of a watermark by using the Transparency property.

Important

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

  • Syntax

    expression.ActiveDocument.Sections.Item(Index).WaterMarks.Item(Index).Transparency

    expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Obtain all watermarks from a single Section object.
      const waterMarks = await app.ActiveDocument.Sections.Item(1).WaterMarks;
    
      // Obtain a single WaterMark object.
      const waterMark = await waterMarks.Item(1);
    
      // Specify the transparency of the watermark.
      waterMark.Transparency = 0;
    }