interface TextObjectType {
    createCJKFont: (
        fontName: string,
        fontsize: number,
        doc: DocType,
    ) => Promise<null | PDFFontType>;
    destroy: () => Promise<void>;
    getCharCount: () => Promise<number>;
    getCharInfo: (index: number) => Promise<CharInfo>;
    getCharRect: (index: number) => Promise<null | Rect>;
    getFont: () => Promise<null | PDFFontType>;
    getFontSize: () => Promise<number>;
    getIndex: () => Promise<number>;
    getItemCount: () => Promise<number>;
    getPosX: () => Promise<number>;
    getPosY: () => Promise<number>;
    getTextMatrix: () => Promise<Matrix>;
    options?: Options;
    reCalcPositionData: () => Promise<void>;
    setCJKText: (text: string, font: PDFFontType) => Promise<void>;
    setColorState: (state: ColorStateType) => Promise<void>;
    setEmpty: () => Promise<void>;
    setIndex: (index: number) => Promise<void>;
    setPosition: (x: number, y: number) => Promise<void>;
    setText: (text: string) => Promise<void>;
    setTextState: (textState: TextStateType) => Promise<void>;
    transform: (matrix: Matrix) => Promise<void>;
}

Implemented by

Properties

createCJKFont: (
    fontName: string,
    fontsize: number,
    doc: DocType,
) => Promise<null | PDFFontType>

Create a CJK font for the text object.

Type declaration

    • (fontName: string, fontsize: number, doc: DocType): Promise<null | PDFFontType>
    • Parameters

      • fontName: string

        The font name to create.

      • fontsize: number

        The font size to create.

      • 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: () => Promise<void>

Destroy the TextObject instance.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

getCharCount: () => Promise<number>

Get the count of characters in the text object.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

      Return the count of characters in the text object.

getCharInfo: (index: number) => Promise<CharInfo>

Get the information of specified character.

Type declaration

    • (index: number): Promise<CharInfo>
    • Parameters

      • index: number

        Specify zero-based character index in the text object.

      Returns Promise<CharInfo>

      Return the information of specified character.

getCharRect: (index: number) => Promise<null | Rect>

Get the rect of specified character.

Type declaration

    • (index: number): Promise<null | Rect>
    • Parameters

      • index: number

        Specify zero-based character index in the text object.

      Returns Promise<null | Rect>

      Return the rect of specified character.

getFont: () => Promise<null | PDFFontType>

Get the font of the current text object.

Type declaration

    • (): Promise<null | PDFFontType>
    • Returns Promise<null | PDFFontType>

      Return the font of the current text object.

getFontSize: () => Promise<number>

Get the font size of the current text object.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

      Return the font size of the current text object.

getIndex: () => Promise<number>

Get the index of the text object.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

      Return the index of the text object.

getItemCount: () => Promise<number>

Get the count of text object items.

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

      Return the count of text object items.

getPosX: () => Promise<number>

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

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

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

getPosY: () => Promise<number>

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

Type declaration

    • (): Promise<number>
    • Returns Promise<number>

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

getTextMatrix: () => Promise<Matrix>

Get the text matrix of the current object.

Type declaration

    • (): Promise<Matrix>
    • Returns Promise<Matrix>

      Return the text matrix of the current object.

options?: Options
reCalcPositionData: () => Promise<void>

Recalculate the position data of the text object.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

setCJKText: (text: string, font: PDFFontType) => Promise<void>

Set the CJK text for the text object.

Type declaration

    • (text: string, font: PDFFontType): Promise<void>
    • 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);
setColorState: (state: ColorStateType) => Promise<void>

Set the color state of the text object.

Type declaration

setEmpty: () => Promise<void>

Set the text object to empty.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

setIndex: (index: number) => Promise<void>

Set the index of the text object.

Type declaration

    • (index: number): Promise<void>
    • Parameters

      • index: number

        The index to set.

      Returns Promise<void>

setPosition: (x: number, y: number) => Promise<void>

Set the position of the text object.

Type declaration

    • (x: number, y: number): Promise<void>
    • Parameters

      • x: number

        The x-coordinate.

      • y: number

        The y-coordinate.

      Returns Promise<void>

let textObj = await TextObject.create();
await textObject.setPosition(100, 100);
setText: (text: string) => Promise<void>

Set the text of the text object.

Type declaration

    • (text: string): Promise<void>
    • Parameters

      • text: string

        The text to set.

      Returns Promise<void>

let textObj = await TextObject.create();
await textObject.setText('Hello World!');
setTextState: (textState: TextStateType) => Promise<void>

Set the text state of the text object.

Type declaration

let textObj = await TextObject.create();
let textState = await TextState.create();
await textState.setFontSize(25);
await textObject.setTextState(textState
transform: (matrix: Matrix) => Promise<void>

Transform the text object by the specified matrix.

Type declaration

    • (matrix: Matrix): Promise<void>
    • Parameters

      • matrix: Matrix

        The matrix to transform.

      Returns Promise<void>