Skip to main content

SetText

Replaces all content of the current table cell with the specified text, preserving the formatting of the first paragraph.

Syntax

expression.SetText(text);

expression - A variable that represents a ApiTableCell class.

Parameters

NameRequired/OptionalData typeDefaultDescription
textRequiredstringThe text to set.

Returns

ApiRun

Example

Replace all content in a table cell with plain text in a PDF.

// How do I overwrite the text of a table cell in a PDF?

// Clear an existing cell and write a new sentence into it, preserving formatting in a PDF.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const table = Api.CreateTable(2, 2);
const cell = table.GetRow(0).GetCell(0);
cell.AddText("Original cell content.");
cell.SetText("Updated cell content.");

page.AddObject(table);