ApiWatermarkSettings

new ApiWatermarkSettings()

Class representing the settings which are used to create a watermark.

Methods

Name Description
GetClassType

Returns a type of the ApiWatermarkSettings class.

GetDirection

Returns the direction of the watermark in the document.

GetImageHeight

Returns the height of the watermark image in the document.

GetImageURL

Returns the image URL of the watermark in the document.

GetImageWidth

Returns the width of the watermark image in the document.

GetOpacity

Returns the opacity of the watermark in the document.

GetText

Returns the text of the watermark in the document.

GetTextPr

Returns the text properties of the watermark in the document.

GetType

Returns the type of the watermark in the document.

SetDirection

Sets the direction of the watermark in the document.

SetImageSize

Sets the size (width and height) of the watermark image in the document.

SetImageURL

Sets the image URL of the watermark in the document.

SetOpacity

Sets the opacity of the watermark in the document.

SetText

Sets the text of the watermark in the document.

SetTextPr

Sets the text properties of the watermark in the document.

SetType

Sets the type of the watermark in the document.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
oDocument.InsertWatermark("Watermark", true);
var oSettings = oDocument.GetWatermarkSettings();
oSettings.SetType("image");
oSettings.SetImageURL("https://api.onlyoffice.com/content/img/docbuilder/examples/onlyoffice_logo.png");
oSettings.SetImageSize(100 * 36000, 100 * 36000);
oSettings.SetDirection("horizontal");
oSettings.SetOpacity(100);
oDocument.SetWatermarkSettings(oSettings);
var sClassType = oSettings.GetClassType();
var sType = oSettings.GetType();
var sDirection = oSettings.GetDirection();
var nOpacity = oSettings.GetOpacity();
var sImage = oSettings.GetImageURL();
var nWidth = oSettings.GetImageWidth();
var nHeight = oSettings.GetImageHeight();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("Class type: " + sClassType);
oParagraph.AddLineBreak();
oParagraph.AddText("Watermark type: " + sType);
oParagraph.AddLineBreak();
oParagraph.AddText("Watermark image URL: "+ sImage);
oParagraph.AddLineBreak();
oParagraph.AddText("Watermark direction: " + sDirection);
oParagraph.AddLineBreak();
oParagraph.AddText("Watermark opacity: "+ nOpacity);
oParagraph.AddLineBreak();
oParagraph.AddText("Watermark image width: "+ nWidth);
oParagraph.AddLineBreak();
oParagraph.AddText("Watermark image height: "+ nHeight);
builder.SaveFile("docx", "ApiWatermarkSettings.docx");
builder.CloseFile();

Resulting document