跳到主要内容

SlidesToJSON

Converts the slides from the current ApiPresentation object into the JSON objects.

Syntax

expression.SlidesToJSON(nStart, nStart, bWriteLayout, bWriteMaster, bWriteAllMasLayouts, bWriteTableStyles);

expression - A variable that represents a ApiPresentation class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nStartOptionalboolean0The index to the start slide.
nStartOptionalbooleanApiPresentation.GetSlidesCount() - 1The index to the end slide.
bWriteLayoutOptionalbooleanfalseSpecifies if the slide layout will be written to the JSON object or not.
bWriteMasterOptionalbooleanfalseSpecifies if the slide master will be written to the JSON object or not (bWriteMaster is false if bWriteLayout === false).
bWriteAllMasLayoutsOptionalbooleanfalseSpecifies if all child layouts from the slide master will be written to the JSON object or not.
bWriteTableStylesOptionalbooleanfalseSpecifies whether to write used table styles to the JSON object (true) or not (false).

Returns

JSON[]

Example

This example shows how to convert the slides from the current ApiPresentation object into the JSON objects.

// How to convert slides to JSON objects.

// Get JSON representations of each slide from the presentation.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const json = presentation.SlidesToJSON(0, 0, true, true, true, true);
const allSlidesFromJSON = Api.FromJSON(json);
const slideFromJSON = allSlidesFromJSON[0];
presentation.AddSlide(slideFromJSON);
const classType = slideFromJSON.GetClassType();

const fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const drawing = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
drawing.SetPosition(608400, 1267200);
drawing.SetSize(300 * 36000, 130 * 36000);
slide.AddObject(drawing);

const docContent = drawing.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("Class type = " + classType);