TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

SetText

SetText(sText)

Sets the text of the watermark in the document.

Parameters:

Name Type Description
sText string

The watermark text.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
oDocument.InsertWatermark("Watermark", true);
var oSettings = oDocument.GetWatermarkSettings();
oSettings.SetText("ONLYOFFICE");
oDocument.SetWatermarkSettings(oSettings);
var sText = oSettings.GetText();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("Watermark text: " + sText);
builder.SaveFile("docx", "SetText.docx");
builder.CloseFile();

Resulting document