# EditTextToolApi.setText()

```ts
setText(blockId: string, text: string): Promise<void>
```

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.

- Kind: method
- Since: 1.0.0

| 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_STATE` while the tool is not active — without `edit-text` it 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_LICENSED` without `extract` for any text but `''`.
- `INVALID_STATE` when other blocks keep being opened while it waits for fonts (a text block that kept losing its editing surface to another).
- `PAGE_ERROR` when the block's page could not be loaded.

```ts
await viewer.tools.editText.setText(total.id, 'Total: $1,299.00');
await viewer.tools.editText.setText(footnote.id, ''); // removes the block
```

Part of [EditTextToolApi](https://kernstra.com/docs/web-sdk/api/viewer-tools-edittext) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/viewer-tools-edittext/settext
