Skip to content

DevExpress-Examples/presentation-api-get-started

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevExpress Presentation API Library – Get Started

This example creates a new presentation, adds three slides, and populates slides with content.

Slide #1

slide 1

Slide #2

slide 2

Slide #3

slide 3

Important

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use our Office File API library in production code. For pricing information, refer to the following webpage: DevExpress Subscriptions.

Implementation Details

  • Use the Presentation() parameterless constructor to create a new presentation.

    Presentation presentation = new Presentation();
  • A newly created presentation contains a single default slide master. The Slide Master is a top-level template slide that you can use as a base for other slides. Slide masters store content, layouts and settings that you can share among derived slides. The default slide master goes first in the Presentation.SlideMasters collection.

    SlideMaster slideMaster = presentation.SlideMasters[0];
  • To create a slide, initialize a Slide object and add it to the Presentation.Slides collection. For each slide, specify the layout type as a constructor parameter. In this example, slides use predefined layouts stored in the slide master. To obtain a layout from SlideMaster.Layouts, call the Get or GetOrCreate method.

    Slide slide1 = new Slide(slideMaster.Layouts.Get(SlideLayoutType.Title));
    //...
    presentation.Slides.Add(slide1);
  • Layouts add placeholder shapes to slides. Use the Slide.Shapes collection to access placeholder shapes and populate them with content.

    foreach (Shape shape in slide1.Shapes) {
        if (shape.PlaceholderSettings.Type is PlaceholderType.CenteredTitle) {
            shape.TextArea = new TextArea("Daily Testing Status Report");
        }
        if (shape.PlaceholderSettings.Type is PlaceholderType.Subtitle) {
            shape.TextArea = new TextArea($"{DateTime.Now: dddd, MMMM d, yyyy}");
        }
    }
  • You can save the resulting presentation to a PPTX file and export it to a PDF file:

    FileStream outputStream = new FileStream(@"..\..\..\data\my-presentation.pptx", FileMode.Create);
    presentation.SaveDocument(outputStream);
    outputStream.Dispose();
    
    presentation.ExportToPdf(new FileStream(@"..\..\..\data\exported-document.pdf", FileMode.Create));

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Creates a presentation with slides and saves it to PPTX and PDF.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages