Get Started
Documentation

ApiDrawing

new ApiDrawing()

Class representing a graphical object.

Methods

Name Description
AddBreak

Inserts a break at the specified location in the main document.

Copy

Copy the graphic object.

Delete

Deletes the graphic object.

Fill

Sets the fill formatting properties for the specified graphic object.

GetClassType

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

GetNextDrawing

Gets the next inline drawing object. Throws an error if this inline drawing object is the last.

GetParentContentControl

Gets the parent content control that contains the graphic object.

GetParentParagraph

Gets the parent paragraph that contains the graphic object.

GetParentTable

Gets the parent table that contains the graphic object.

GetParentTableCell

Gets the parent table cell that contains the graphic object.

GetPrevDrawing

Gets the previous inline drawing object. Throws an error if this inline drawing object is the first.

InsertInContentControl

Wraps the graphic object with a rich text content control.

InsertParagraph

Inserts a paragraph at the specified position.

ScaleHeight

Scales the height of the figure using the specified coefficient.

ScaleWidth

Scales the width of the graphic object using the specified ratio.

Select

Selects the graphic object.

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.

SetHorFlip

Horizontal Reflection.

SetHorPosition

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

SetOutLine

Sets the outline properties for the specified graphic 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.

SetVertFlip

Vertical reflection.

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