Api

new Api()

Methods

Name Description
attachEvent

Subscribes to the specified event and calls the callback function when the event fires.

CreateBlipFill

Creates a blip fill to apply to the object using the selected image as the object background.

CreateBullet

Creates a bullet for a paragraph with the character or symbol specified with the sSymbol parameter.

CreateChart

Creates a chart with the parameters specified.

CreateGradientStop

Creates a gradient stop used for different types of gradients.

CreateGroup

Creates a group of drawings.

CreateImage

Creates an image with the parameters specified.

CreateLayout

Creates a new slide layout and adds it to the slide master if it is specified.

CreateLinearGradientFill

Creates a linear gradient fill to apply to the object using the selected linear gradient as the object background.

CreateMaster

Creates a new slide master.

CreateNoFill

Creates no fill and removes the fill from the element.

CreateNumbering

Creates a bullet for a paragraph with the numbering character or symbol specified with the sType parameter.

CreateOleObject

Creates an OLE object with the parameters specified.

CreateParagraph

Creates a new paragraph.

CreatePatternFill

Creates a pattern fill to apply to the object using the selected pattern as the object background.

CreatePlaceholder

Creates a new placeholder.

CreatePresetColor

Creates a color selecting it from one of the available color presets.

CreateRadialGradientFill

Creates a radial gradient fill to apply to the object using the selected radial gradient as the object background.

CreateRGBColor

Creates an RGB color setting the appropriate values for the red, green and blue color components.

CreateRun

Creates a new smaller text block to be inserted to the current paragraph or table.

CreateSchemeColor

Creates a complex color scheme selecting from one of the available schemes.

CreateShape

Creates a shape with the parameters specified.

CreateSlide

Creates a new slide.

CreateSolidFill

Creates a solid fill to apply to the object using a selected solid color as the object background.

CreateStroke

Creates a stroke adding shadows to the element.

CreateTable

Creates a table.

CreateTextPr

Creates the empty text properties.

CreateTheme

Creates a new presentation theme.

CreateThemeColorScheme

Creates a new theme color scheme.

CreateThemeFontScheme

Creates a new theme font scheme.

CreateThemeFormatScheme

Creates a new theme format scheme.

CreateWordArt

Creates a Text Art object with the parameters specified.

detachEvent

Unsubscribes from the specified event.

FromJSON

Converts the specified JSON object into the Document Builder object of the corresponding type.

GetFullName

Returns the full name of the currently opened file.

GetPresentation

Returns the main presentation.

ReplaceTextSmart

Replaces each paragraph (or text in cell) in the select with the corresponding text from an array of strings.

Save

Saves changes to the specified document.

Example

Copy code
builder.CreateFile("pptx");
var oPresentation = Api.GetPresentation();
var oImageTitle = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/api-slide-1.jpg", 350 * 36000, 195* 36000);
var oImageSlideOne = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/api-slide-2.jpg", 350 * 36000, 195* 36000);
var oSlide = oPresentation.GetSlideByIndex(0);
oSlide.RemoveAllObjects();
oSlide.AddObject(oImageTitle);
var oFill = Api.CreateNoFill();
var oStroke = Api.CreateStroke(0, oFill);
var oShapeTitle = Api.CreateShape("rect", 150 * 36000, 20 * 36000, oFill, oStroke);
var oShapeFooter = Api.CreateShape("rect", 150 * 36000, 20 * 36000, oFill, oStroke);
var oShapeChartTitle = Api.CreateShape("rect", 200 * 36000, 20 * 36000, oFill, oStroke);
oShapeTitle.SetPosition(40 * 36000, 55 * 36000);
oShapeFooter.SetPosition(170 * 36000, 175 * 36000);
oShapeChartTitle.SetPosition(135 * 36000, 3 * 36000);
var oDocContent = oShapeTitle.GetDocContent();
var oParagraph = oDocContent.GetElement(0);
var oRun = Api.CreateRun();
var oTextPr = oRun.GetTextPr();
oTextPr.SetFontSize(96);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(115, 81, 68));
oTextPr.SetFill(oFill);
oTextPr.SetFontFamily("Tahoma");
oParagraph.SetJc("left");
oRun.AddText("TEAM BUILDING");
oRun.AddLineBreak();
oParagraph.AddElement(oRun);
oSlide.AddObject(oShapeTitle);
oRun = Api.CreateRun();
oTextPr = oRun.GetTextPr();
oTextPr.SetFontSize(62);
oTextPr.SetFill(oFill);
oRun.AddText("How we grow relationships through creativity");
oParagraph.AddElement(oRun);
oSlide.AddObject(oShapeTitle);

oDocContent = oShapeFooter.GetDocContent();
oParagraph = oDocContent.GetElement(0);
oRun = Api.CreateRun();
oTextPr = oRun.GetTextPr();
oTextPr.SetFontSize(56);
oTextPr.SetFill(oFill);
oRun.AddText("HR Team General Report");
oParagraph.AddElement(oRun);
oSlide.AddObject(oShapeFooter);

oSlide = Api.CreateSlide();
oSlide.RemoveAllObjects();
oSlide.AddObject(oImageSlideOne);
oPresentation.AddSlide(oSlide);

var oChart = Api.CreateChart("bar", [
[6, 10, 15],
[8, 18, 27]
], ["Number of team's ideas used for corp events", "Number of new cross-team projects"], [2020, 2021, 2022], 4051300, 2347595, 48);
oChart.SetVerAxisTitle("", 10);
oChart.SetHorAxisTitle("", 11);
oChart.SetLegendPos("bottom");
oChart.SetShowDataLabels(false, false, true, false);
oChart.SetTitle("", 26);
oChart.SetSize(269.5 * 36000, 129 * 36000);
oChart.SetPosition(40 * 36000, 33 * 36000);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(196, 230, 214));
oChart.SetSeriesFill(oFill, 0, false);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(244, 80, 104));
oChart.SetHorAxisLablesFontSize(24);
oChart.SetLegendFontSize(24);
oChart.SetVertAxisLablesFontSize(24);
oChart.SetSeriesFill(oFill, 1, false);
oSlide.AddObject(oChart);

oDocContent = oShapeChartTitle.GetDocContent();
oParagraph = oDocContent.GetElement(0);
oRun = Api.CreateRun();
oTextPr = oRun.GetTextPr();
oTextPr.SetFontSize(76);
oFill = Api.CreateSolidFill(Api.CreateRGBColor(115, 81, 68));
oTextPr.SetFill(oFill);
oTextPr.SetFontFamily("Tahoma");
oParagraph.SetJc("left");
oRun.AddText("Collaboration between teams");
oRun.AddLineBreak();
oParagraph.AddElement(oRun);
oSlide.AddObject(oShapeChartTitle);

Api.Save();
builder.SaveFile("pptx", "Api.pptx");
builder.CloseFile();

Resulting document