Resource Base
Table of contents

Class TextDrawingItem

The TextDrawingItem class extends the functionality of the DrawingItem class and is specifically tailored to handle text-related drawing operations.

Name Description
constructor TextDrawingItem() Constructor for the class.
getText() Retrieves the current text being used for drawing.
setText() Sets the text to be used for drawing.
getTextRect() Returns the rectangle area within which the text is drawn.
setTextRect() Sets the rectangle area within which the text should be drawn.

TextDrawingItem

Constructor for the class.

constructor(
    text: string,
    rect: Rect,
    drawingStyleId?: number
)

Parameters

text: the text to be drawn.

rect: defines the rectangle area within which the text will be drawn.

drawingStyleId: [Optional] the unique ID of the DrawingStyle to apply to this DrawingItem.

Code Snippet

let cameraView = cameraEnhancer.getCameraView();
let drawingLayer = cameraView.createDrawingLayer();
let textItem = new Dynamsoft.DCE.TextDrawingItem(
    "Hello World", 
    {
        x: 100, 
        y: 200, 
        width: 640, 
        height: 360, 
        isMeasuredInPercentage: false
    },
    3
);
drawingLayer.addDrawingItem(textItem);

See also

Rect

getText

Retrieves the current text being used for drawing.

getText(): string;

Parameters

None.

Return Value

The current text being used for drawing.

Code Snippet

textItem.getText();

setText

Sets the text to be used for drawing. This method allows changing the text after the object has been instantiated.

Invoke renderAll() for the change to take effect if the DrawingItem has already been added to a DrawingLayer.

setText(text: string): void;

Parameters

text: the text to be drawn.

Return Value

None.

Code Snippet

textItem.setText(/*A-New-Text*/);

getTextRect

Returns the rectangle area within which the text is drawn.

getTextRect(): Rect;

Parameters

None.

Return Value

The rectangle area within which the text is drawn.

Code Snippet

textItem.getTextRect();

setTextRect

Sets the rectangle area within which the text should be drawn. This method allows for the adjustment of position and size of the text.

The change takes effect right away.

setTextRect(rect: Rect): void;

Parameters

rect: defines the rectangle area within which the text should be drawn.

Return Value

None.

Code Snippet

textItem.setTextRect(
    {
        height: 100, 
        width:300,
        x: 200,
        y :200
    }
);

See Also

Rect

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version(4.0.2)
  • Version 4.x
    • Version 4.0.1
    • Version 4.0.0
  • Version 3.x
    • Version 3.3.10
    • Version 3.3.9
    • Version 3.3.8
    • Version 3.3.7
    • Version 3.3.6
    • Version 3.3.5
    • Version 3.3.4
    • Version 3.3.3
    • Version 3.3.2
    • Version 3.3.1
    • Version 3.3.0
    • Version 3.2.0
    • Version 3.1.0
    • Version 3.0.1
    • Version 3.0.0
  • Version 2.x
    • Version 2.3.5
    • Version 2.3.2
    • Version 2.3.1
    • Version 2.3.0
    • Version 2.1.4
    • Version 2.1.3
    • Version 2.1.0
    • Version 2.0.0
Change +