Get Started
Usage API
More information

ToJSON

ToJSON() → { JSON }

Converts the ApiDrawing object into the JSON object.

Parameters:

This method doesn't have any parameters.

Returns:

Type
JSON

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 224, 204), 0);
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 164, 101), 100000);
var oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 5400000);
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var oDrawing = Api.CreateShape("rect", 5930900, 395605, oFill, oStroke);
let json = oDrawing.ToJSON(false, true);
var oDrawingFromJSON = Api.FromJSON(json);
oParagraph.AddDrawing(oDrawingFromJSON);
builder.SaveFile("docx", "ToJSON.docx");
builder.CloseFile();

Resulting document