Get Started
Documentation

SetWrappingStyle

SetWrappingStyle(sType)

Set the wrapping type of this object (image, shape, chart). One of the following wrapping style types can be set:

  • "inline" - the object is considered to be a part of the text, like a character, so when the text moves, the object moves as well. In this case the positioning options are inaccessible.
If one of the following styles is selected, the object can be moved independently of the text and positioned on the page exactly:
  • "square" - the text wraps the rectangular box that bounds the object.
  • "tight" - the text wraps the actual object edges.
  • "through" - the text wraps around the object edges and fills in the open white space within the object.
  • "topAndBottom" - the text is only above and below the object.
  • "behind" - the text overlaps the object.
  • "inFront" - the object overlaps the text.

Parameters:

Name Type Description
sType "inline" | "square" | "tight" | "through" | "topAndBottom" | "behind" | "inFront" The wrapping style type available for the object.

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 (horizontally) is half an inch (457200 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(457200, 457200, 457200, 0);
oDrawing.SetWrappingStyle("square");
oParagraph.AddDrawing(oDrawing);
builder.SaveFile("docx", "SetWrappingStyle.docx");
builder.CloseFile();

Resulting document