Skip to main content

ToJSON

Converts the ApiTextPr object into the JSON object.

Inherited from ApiTextPr.ToJSON.

Example

Convert the text properties object into the JSON object in a document.

// How to get a JSON from the text properties in a document.

// Convert the text properties to json and add it to the document.

let doc = Api.GetDocument();
let textPr = doc.GetDefaultTextPr();
textPr.SetFontFamily("Comic Sans MS");
let json = textPr.ToJSON(true);
let textPrFromJSON = Api.FromJSON(json);
textPrFromJSON.SetFontSize(30);
let paragraph = doc.GetElement(0);
paragraph.AddText("A sample text with the font size set to 15 points using the text properties.");
paragraph.SetTextPr(textPrFromJSON);