This example creates a new presentation, adds three slides, and populates slides with content.
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.
Use the
Presentation()parameterless constructor to create a new presentation.Presentationpresentation=newPresentation();
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.SlideMasterscollection.SlideMasterslideMaster=presentation.SlideMasters[0];
To create a slide, initialize a
Slideobject and add it to thePresentation.Slidescollection. 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 fromSlideMaster.Layouts, call theGetorGetOrCreatemethod.Slideslide1=newSlide(slideMaster.Layouts.Get(SlideLayoutType.Title));//...presentation.Slides.Add(slide1);
Layouts add placeholder shapes to slides. Use the
Slide.Shapescollection to access placeholder shapes and populate them with content.foreach(Shapeshapeinslide1.Shapes){if(shape.PlaceholderSettings.TypeisPlaceholderType.CenteredTitle){shape.TextArea=newTextArea("Daily Testing Status Report");}if(shape.PlaceholderSettings.TypeisPlaceholderType.Subtitle){shape.TextArea=newTextArea($"{DateTime.Now: dddd, MMMM d, yyyy}");}}
You can save the resulting presentation to a PPTX file and export it to a PDF file:
FileStreamoutputStream=newFileStream(@"..\..\..\data\my-presentation.pptx",FileMode.Create);presentation.SaveDocument(outputStream);outputStream.Dispose();presentation.ExportToPdf(newFileStream(@"..\..\..\data\exported-document.pdf",FileMode.Create));
(you will be redirected to DevExpress.com to submit your response)


