EditTextToolApi.setText()
Replaces a block's text, opening it first if needed. An empty string removes the block, as the toolbar's delete does. Without
extract only that is allowed; retyping rejects with FEATURE_NOT_LICENSED, as it opens the block. A block read as right-aligned — an amount in a column, a heading over values set flush under it — keeps its right edge and grows to the left, exactly as when typed.methodEditingsince 1.0.0
Signature
setText(blockId: string, text: string): Promise<void>
Parameters
| Parameter | Type | Description |
|---|---|---|
| blockId | string | A block id from listBlocks() of the current detection pass. |
| text | string | The new text; '' removes the block. |
Returns
Promise<void>
Throws
INVALID_STATEwhile the tool is not active — withoutedit-textit cannot be activated.INVALID_ARGUMENT, the text left as it was, when it holds a character no available font can draw; or for a block id that names no block.FEATURE_NOT_LICENSEDwithoutextractfor any text but''.INVALID_STATEwhen other blocks keep being opened while it waits for fonts (a text block that kept losing its editing surface to another).PAGE_ERRORwhen the block's page could not be loaded.
Example
TypeScript
await viewer.tools.editText.setText(total.id, 'Total: $1,299.00'); await viewer.tools.editText.setText(footnote.id, ''); // removes the block