Get Started
Usage API
More information

Structure of a presentation

A presentation document has a more simple structure than that of a text document, most of the presentation elements are nested within the slide element with all the other elements placed on it. The single or multiple slide elements are a part of the presentation element.

If you need all the slides to contain the same fonts and images, the slide master should be used. It consists of the same elements as the slide.

The layout can be added to the slide to specify its structure. Also some drawn objects - images, shapes, charts - can be placed directly to the slide or slide layout. The placeholder element can be added to the shape.

The text cannot be placed directly to the slide, it can be only grouped to paragraphs and added to the shapes or tables. For the sake of convenience (as it is always easier to work with smaller blocks than with larger ones) the text is usually divided into small text portions called runs. Each paragraph can consist either of only one text run or have dozens of them inside, depending on the paragraph complexity.

Thus any presentation document structure with ONLYOFFICE Document Builder API used to create it can be outlined like this:

ONLYOFFICE Document Builder API

Presentation creation, global color, theme and fill/stroke settings:
Api, ApiFill, ApiBullet, ApiStroke, ApiGradientStop, ApiUniColor, ApiPresetColor, ApiRGBColor, ApiSchemeColor, ApiTheme, ApiThemeColorScheme, ApiThemeFontScheme, ApiThemeFormatScheme

Presentation

Set presentation sizes, get current slide:
ApiPresentation

Slide

Add objects to the slide, set background:
ApiSlide

Layout

Add objects to the layout, set background:
ApiLayout

Image

Common object properties, current image properties:
ApiDrawing, ApiImage

Chart

Common object properties, current chart properties:
ApiDrawing, ApiChart

Shape

Common object properties, current shape properties:
ApiDrawing, ApiShape.

Paragraph

Common paragraph properties, current paragraph properties:
ApiParaPr, ApiParagraph

Text run

Common text properties, current text run properties:
ApiTextPr, ApiRun

Placeholder

Current placeholder properties:
ApiPlaceholder

Table

Common object properties, current table properties:
ApiDrawing, ApiTable.

Table row

Current table row properties:
ApiTableRow

Table cell

Current table cell properties:
ApiTableCell

Paragraph

Common paragraph properties, current paragraph properties:
ApiParaPr, ApiParagraph

Text run

Common text properties, current text run properties:
ApiTextPr, ApiRun

Table cell

Current table cell properties:
ApiTableCell

Paragraph

Common paragraph properties, current paragraph properties:
ApiParaPr, ApiParagraph

Text run

Common text properties, current text run properties:
ApiTextPr, ApiRun

Slide master

Add objects to the slide master, set background:
ApiMaster

Layout

Add objects to the layout, set background:
ApiLayout

Image

Common object properties, current image properties:
ApiDrawing, ApiImage

Chart

Common object properties, current chart properties:
ApiDrawing, ApiChart

Shape

Common object properties, current shape properties:
ApiDrawing, ApiShape.

Paragraph

Common paragraph properties, current paragraph properties:
ApiParaPr, ApiParagraph

Text run

Common text properties, current text run properties:
ApiTextPr, ApiRun

Placeholder

Current placeholder properties:
ApiPlaceholder

Table

Common object properties, current table properties:
ApiDrawing, ApiTable.

Table row

Current table row properties:
ApiTableRow

Table cell

Current table cell properties:
ApiTableCell

Paragraph

Common paragraph properties, current paragraph properties:
ApiParaPr, ApiParagraph

Text run

Common text properties, current text run properties:
ApiTextPr, ApiRun

Table cell

Current table cell properties:
ApiTableCell

Paragraph

Common paragraph properties, current paragraph properties:
ApiParaPr, ApiParagraph

Text run

Common text properties, current text run properties:
ApiTextPr, ApiRun

 

Creating a new presentation

The simplest example presentation with a single slide without any objects can be built with the help of ONLYOFFICE Document Builder using the following code:

builder.CreateFile("pptx");                      // create a presentation file in the .pptx format with ONLYOFFICE Document Builder
var oPresentation = Api.GetPresentation();       // create a new 'oPresentation' variable and get the created presentation contents
var oSlide = oPresentation.GetSlideByIndex(0);   // get the first slide
oSlide.RemoveAllObjects();                       // remove all objects from the first slide
builder.SaveFile("pptx", "example.pptx");        // save the resulting presentation as a file in the .pptx format with a new 'example.pptx' name
builder.CloseFile();                             // close the presentation file and finish work with ONLYOFFICE Document Builder

Opening an existing presentation

If you want to edit an already existing presentation, you can open it using ONLYOFFICE Document Builder, get its elements and change them however you need. The only difference from a presentation editor in this case will be that you will not need this presentation editor. The presentation is opened the following way:

builder.OpenFile("https://example.com/mypresentation.pptx");         // use a path to an existing 'mypresentation.pptx' presentation file to open it with ONLYOFFICE Document Builder
var oPresentation = Api.GetPresentation();       // create a new 'oPresentation' variable and get the created presentation contents
var oSlide = oPresentation.GetSlideByIndex(0);   // get the first slide
oSlide.RemoveAllObjects();                       // remove all objects from the first slide
builder.SaveFile("pptx", "example.pptx");        // save the resulting presentation as a file in the .pptx format with a new 'example.pptx' name
builder.CloseFile();                             // close the presentation file and finish work with ONLYOFFICE Document Builder

As you can see you just need to use the builder.OpenFile(); method of the CDocBuilder class with the path to the necessary presentation as an argument to open it. In the above example we open mypresentation.pptx presentation, get its first slide and remove all objects from it. The same way any other presentation element can be changed.

Use the appropriate API documentation sections to find out which methods allow you to change certain document and presentation element formatting properties.