SetImageSize

SetImageSize(nWidth, nHeight)

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

Parameters:

Name Type Description
nWidth EMU

The watermark image width.

nHeight EMU

The watermark image height.

Returns:

This method doesn't return any data.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
oDocument.InsertWatermark("Watermark");
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);
oDocument.SetWatermarkSettings(oSettings);
var nWidth = oSettings.GetImageWidth();
var nHeight = oSettings.GetImageHeight();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("Watermark image width: "+ nWidth);
oParagraph.AddLineBreak();
oParagraph.AddText("Watermark image height: "+ nHeight);
builder.SaveFile("docx", "SetImageSize.docx");
builder.CloseFile();

Resulting document