ToJSON

function ToJSON(bWriteNumberings: boolean = null, bWriteStyles: boolean = null): JSON

Description

Converts the ApiDrawing object into the JSON object.

Parameters

bWriteNumberingsbooleandefault: null

Specifies if the used numberings will be written to the JSON object or not.

bWriteStylesbooleandefault: null

Specifies if the used styles will be written to the JSON object or not.

Returns

JSON

Try It

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);
var json = oDrawing.ToJSON(false, true);
var oDrawingFromJSON = Api.FromJSON(json);
oParagraph.AddDrawing(oDrawingFromJSON);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).