Get Started
Documentation

ApiDrawing

new ApiDrawing()

Class representing a graphical object.

Methods

Name Description
GetClassType

Get the type of the class based on this base class.

SetDistances

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

SetHorAlign

Specify how the floating object will be horizontally aligned.

SetHorPosition

Set an absolute measurement for the horizontal positioning of the floating object.

SetSize

Set the size of the object (image, shape, chart) bounding box.

SetVerAlign

Specify how the floating object will be vertically aligned.

SetVerPosition

Set an absolute measurement for the vertical positioning of the floating object.

SetWrappingStyle

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.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oGs1, oGs2, oFill, oStroke, oDrawing, oParagraph;
oParagraph = oDocument.GetElement(0);
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", 5930900, 395605, oFill, oStroke);
oDrawing.SetSize(2000 * 635, 2000 * 635);
oDrawing.SetWrappingStyle("inFront");
oDrawing.SetHorAlign("margin", "right");
oDrawing.SetVerAlign("page", "top");
oParagraph.AddDrawing(oDrawing);
builder.SaveFile("docx", "ApiDrawing.docx");
builder.CloseFile();

Resulting document