Get Started
Documentation

SetDistances

SetDistances(nLeft, nTop, nRight, nBottom)

Specify the minimum distance which will be maintained between the edges of this drawing object and any subsequent text.

Parameters:

Name Type Description
nLeft EMU The distance from the left side of the current object and the subsequent text run measured in English measure units.
nTop EMU The distance from the top side of the current object and the preceding text run measured in English measure units.
nRight EMU The distance from the right side of the current object and the subsequent text run measured in English measure units.
nBottom EMU The distance from the bottom side of the current object and the subsequent text run measured in English measure units.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oGs1, oGs2, oFill, oStroke, oDrawing, oParagraph;
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a paragraph with a shape. ");
oParagraph.AddText("The text wraps the rectangular box that bounds the object. ");
oParagraph.AddText("The distance between the shape and the text is 1 inch (914400 English measure units).");
oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 224, 204), 0);
oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(155, 64, 1), 100000);
oFill = Api.CreateRadialGradientFill([oGs1, oGs2]);
oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oDrawing = Api.CreateShape("rect", 1908000, 1404000, oFill, oStroke);
oDrawing.SetDistances(914400, 0, 914400, 0);
oDrawing.SetWrappingStyle("square");
oParagraph.AddDrawing(oDrawing);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is another paragraph.");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "SetDistances.docx");
builder.CloseFile();

Resulting document