Get Started
Usage API
More information

ApiDrawing

new ApiDrawing()

Class representing a graphical object.

Methods

Name Description
AddBreak

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

Copy

Copies the current graphic object.

Delete

Deletes the current graphic object.

Fill

Sets the fill formatting properties to the current graphic object.

GetClassType

Returns a type of the ApiDrawing class.

GetNextDrawing

Returns the next inline drawing object if exists.

GetParentContentControl

Returns a parent content control that contains the graphic object.

GetParentParagraph

Returns a parent paragraph that contains the graphic object.

GetParentTable

Returns a parent table that contains the graphic object.

GetParentTableCell

Returns a parent table cell that contains the graphic object.

GetPrevDrawing

Returns the previous inline drawing object if exists.

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 figure using the specified coefficient.

Select

Selects the current graphic object.

SetDistances

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

SetHorAlign

Specifies how the floating object will be horizontally aligned.

SetHorFlip

Flips the current drawing horizontally.

SetHorPosition

Sets the absolute measurement for the horizontal positioning of the floating object.

SetOutLine

Sets the outline properties to the specified graphic object.

SetSize

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

SetVerAlign

Specifies how the floating object will be vertically aligned.

SetVerPosition

Sets the absolute measurement for the vertical positioning of the floating object.

SetVertFlip

Flips the current drawing vertically.

SetWrappingStyle

Sets the wrapping type of the current 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");
oDocument = Api.GetDocument();
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 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");
oDrawing.SetHorAlign("page", "center");
oParagraph.AddDrawing(oDrawing);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is another paragraph.");
oDocument.Push(oParagraph);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The shape is aligned at the center of the page horizontally.");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiDrawing.docx");
builder.CloseFile();

Resulting document