Implements

Constructors

  • Create a TextObject instance. Instead of creating an instance in new mode, use create to create an instance.

    Parameters

    • Optionaloptions: Options

      Create a TextObject instance with the specified options.

    Returns TextObject

    const pdfArr = await TextObject.create();
    

Properties

options: Options

Methods

  • Create a CJK font for the text object.

    Parameters

    • fontName: string

      The font name to create.

    • fontSize: number
    • doc: DocType

      The document object to create the font.

    Returns Promise<null | PDFFontType>

    Return the created PDFFont object.

    let doc = await app.getActiveDoc();
    let textObj = await TextObject.create();
    let font = await textObject.createCJKFont('SimSun', 12, doc);
  • Destroy the TextObject instance.

    Returns Promise<void>

  • Get the count of characters in the text object.

    Returns Promise<number>

    Return the count of characters in the text object.

  • Get the information of specified character.

    Parameters

    • index: number

      Specify zero-based character index in the text object.

    Returns Promise<CharInfo>

    Return the information of specified character.

  • Get the rect of specified character.

    Parameters

    • index: number

      Specify zero-based character index in the text object.

    Returns Promise<null | Rect>

    Return the rect of specified character.

  • Get the font size of the current text object.

    Returns Promise<number>

    Return the font size of the current text object.

  • Get the index of the text object.

    Returns Promise<number>

    Return the index of the text object.

  • Get the count of text object items.

    Returns Promise<number>

    Return the count of text object items.

  • Get the x-coordinate of the origin in the device space.

    Returns Promise<number>

    Return the x-coordinate of the origin in the device space.

  • Get the y-coordinate of the origin in the device space.

    Returns Promise<number>

    Return the y-coordinate of the origin in the device space.

  • Set the CJK text for the text object.

    Parameters

    • text: string

      The text to set.

    • font: PDFFontType

      The font to set.

    Returns Promise<void>

    let doc = await app.getActiveDoc();
    let textObj = await TextObject.create();
    let font = await textObject.createCJKFont('SimSun', 12, doc);
    await textObj.setCJKText('你好,欢迎来到PDF世界!', font);
  • Set the text object to empty.

    Returns Promise<void>

  • Set the index of the text object.

    Parameters

    • index: number

      The index to set.

    Returns Promise<void>

  • Set the position of the text object.

    Parameters

    • x: number

      The x-coordinate.

    • y: number

      The y-coordinate.

    Returns Promise<void>

    let textObj = await TextObject.create();
    await textObject.setPosition(100, 100);
  • Set the text of the text object.

    Parameters

    • text: string

      The text to set.

    Returns Promise<void>

    let textObj = await TextObject.create();
    await textObject.setText('Hello World!');
  • Set the text state of the text object.

    Parameters

    Returns Promise<void>

    let textObj = await TextObject.create();
    let textState = await TextState.create();
    await textState.setFontSize(25);
    await textObject.setTextState(textState
  • Transform the text object by the specified matrix.

    Parameters

    • matrix: Matrix

      The matrix to transform.

    Returns Promise<void>

  • Create a TextObject instance.

    Parameters

    • Optionaloptions: Options

      Create a TextObject instance with the specified options.

    Returns Promise<TextObjectType>

    Return a TextObject instance.

    const pdfArr = await TextObject.create();