Get Started
Documentation

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.

Some drawn objects - images, shapes, charts - can be placed directly to the slide.

The text cannot be placed directly to the slide, it can be only grouped to paragraphs and added to the shapes. 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 and fill/stroke settings:
Api, ApiFill, ApiBullet, ApiStroke, ApiGradientStop, ApiUniColor, ApiPresetColor, ApiRGBColor, ApiSchemeColor

Presentation

Set presentation sizes, get current slide:
ApiPresentation

Slide

Add objects to the slide, set background:
ApiSlide

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, paragraph numbering:
ApiParaPr, ApiParagraph

Text run

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

 

Creating a new presentation

A 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("mypresentation.pptx");         // open an existing 'mypresentation.pptx' presentation file 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.