Web SDKv1.0.0

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

ParameterTypeDescription
blockIdstringA block id from listBlocks() of the current detection pass.
textstringThe 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.

Example

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

More in EditTextToolApi