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.

GetHeight

Returns the height of the current drawing.

GetLockValue

Returns the lock value for the specified lock type of the current drawing.

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.

GetWidth

Returns the width of the current drawing.

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.

SetDrawingPrFromDrawing

Sets the properties from another drawing to the current drawing. The following properties will be copied: horizontal and vertical alignment, distance between the edges of the current drawing object and any subsequent text, wrapping style, drawing name, title and description.

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.

SetLockValue

Sets the lock value to the specified lock type of the current drawing.

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.
ToJSON

Converts the ApiDrawing object into the JSON object.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var 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).");
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0);
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000);
var oFill = Api.CreateRadialGradientFill([oGs1, oGs2]);
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var 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