Skip to main content
All docs
V26.1
  • Presentation Class

    A non-visual component that allows you to generate presentations from scratch and edit existing presentations.

    Namespace: DevExpress.Docs.Presentation

    Assembly: DevExpress.Docs.Presentation.v26.1.dll

    Declaration

    [DXLicenseDocs]
    public class Presentation :
        IDisposable

    Remarks

    The Presentation Document API is a cross-platform .NET library that allows you to create, load, modify, save, and print presentations in code. You can use this library in desktop and web applications that target a variety of platforms (Windows Forms, WPF, ASP.NET Web Forms, ASP.NET MVC, ASP.NET Core, and Blazor).

    To create your first presentation from scratch, follow our step-by-step tutorial:

    Read Tutorial

    Important

    You need a license for the DevExpress Office & PDF File API Subscription or DevExpress Universal Subscription to use the Presentation API.

    Warning

    The Presentation should not be accessed simultaneously by different threads.

    Example

    The following code snippet creates a new presentation, adds three slides, and populates slides with content:

    View Example

    using DevExpress.Docs.Presentation;
    using DevExpress.Docs.Office;
    using DevExpress.Drawing;
    using System.Drawing;
    
    namespace DxPresentationGetStarted;
    
    public class Program {
        public static void Main(string[] _) {
    
            // Create a new presentation and remove the default empty slide
            Presentation presentation = new Presentation();
            presentation.Slides.Clear();
    
            // Specify a custom background color for the slide master to share this background across all child slides
            SlideMaster slideMaster = presentation.SlideMasters[0];
            slideMaster.Background = new CustomSlideBackground(new SolidFill(Color.FromArgb(194, 228, 249)));
    
            // Create a slide with the Title layout
            Slide slide1 = new Slide(slideMaster.Layouts.Get(SlideLayoutType.Title));
            foreach (Shape shape in slide1.Shapes) {
                // Specify the centered title text
                if (shape.PlaceholderSettings.Type is PlaceholderType.CenteredTitle) {
                    shape.TextArea = new TextArea("Daily Testing Status Report");
                }
                // Set the subtitle to the current date
                if (shape.PlaceholderSettings.Type is PlaceholderType.Subtitle) {
                    shape.TextArea = new TextArea($"{DateTime.Now: dddd, MMMM d, yyyy}");
                }
            }
            presentation.Slides.Add(slide1);
    
            // Create a slide based on the Object layout
            Slide slide2 = new Slide(slideMaster.Layouts.GetOrCreate(SlideLayoutType.Object));
            foreach (Shape shape in slide2.Shapes) {
                // Specify the slide title
                if (shape.PlaceholderSettings.Type is PlaceholderType.Title) {
                    shape.TextArea = new TextArea("Today’s Highlights");
                }
                // Add a list of paragraphs to the slide
                if (shape.PlaceholderSettings.Type is PlaceholderType.Body) {
                    TextArea textArea = new TextArea();
                    textArea.Paragraphs.Clear();
                    textArea.Paragraphs.Add(new TextParagraph("5 successful builds"));
                    textArea.Paragraphs.Add(new TextParagraph("2 failed builds"));
                    textArea.Paragraphs.Add(new TextParagraph("12 new bugs reported"));
                    textArea.Paragraphs.Add(new TextParagraph("3 deployments"));
                    textArea.Paragraphs.Add(new TextParagraph("1 rollback"));
                    shape.TextArea = textArea;
                }
            }
            presentation.Slides.Add(slide2);
    
            // Create a slide based on the Object layout
            Slide slide3 = new Slide(slideMaster.Layouts.GetOrCreate(SlideLayoutType.Object));
            foreach (Shape shape in slide3.Shapes.ToList()) {
                // Specify the slide title
                if (shape.PlaceholderSettings.Type is PlaceholderType.Title) {
                    shape.TextArea = new TextArea("Build Status");
                }
                // Add a table to a slide placeholder
                if (shape.PlaceholderSettings.Type is PlaceholderType.Body) {
                    RectangleF rect = presentation.GetActualShapeBounds(slide3, shape);
                    slide3.Shapes.Remove(shape);
    
                    Table table = new Table(5, 5, rect.X, rect.Y, rect.Width, rect.Height);
                    slide3.Shapes.Add(table);
    
                    table[0, 0].TextArea.Text = "Build ID";
                    table[0, 1].TextArea.Text = "Branch";
                    table[0, 2].TextArea.Text = "Status";
                    table[0, 3].TextArea.Text = "Duration";
                    table[0, 4].TextArea.Text = "Triggered By";
    
                    table[1, 0].TextArea.Text = "#5421";
                    table[1, 1].TextArea.Text = "main";
                    table[1, 2].TextArea.Text = "✅  Passed";
                    table[1, 3].TextArea.Text = "4m 30s";
                    table[1, 4].TextArea.Text = "Auto-schedule";
    
                    table[2, 0].TextArea.Text = "#5420";
                    table[2, 1].TextArea.Text = "ui-fix";
                    table[2, 2].TextArea.Text = "❌  Failed";
                    table[2, 3].TextArea.Text = "2m 18s";
                    table[2, 4].TextArea.Text = "Push by dev1";
    
                    table[3, 0].TextArea.Text = "#5419";
                    table[3, 1].TextArea.Text = "main";
                    table[3, 2].TextArea.Text = "✅  Passed";
                    table[3, 3].TextArea.Text = "3m 52s";
                    table[3, 4].TextArea.Text = "Auto-schedule";
    
                    table[4, 0].TextArea.Text = "#5418";
                    table[4, 1].TextArea.Text = "hotfix";
                    table[4, 2].TextArea.Text = "❌  Failed";
                    table[4, 3].TextArea.Text = "5m 1s";
                    table[4, 4].TextArea.Text = "Manual";
    
                    table.Style = new ThemedTableStyle(TableStyleType.LightStyle1);
                    table.HasBandedRows = false;
                }
            }
            presentation.Slides.Add(slide3);
    
            // Add slide numbers and a footer to all slides
            presentation.HeaderFooterManager.AddSlideNumberPlaceholder(presentation.Slides);
            presentation.HeaderFooterManager.AddFooterPlaceholder(presentation.Slides, "ProductXCompany");
    
            // Save the presentation to a PPTX file
            FileStream outputStream = new FileStream(@"..\..\..\data\my-presentation.pptx", FileMode.Create);
            presentation.SaveDocument(outputStream);
            outputStream.Dispose();
    
            // Export the presentation to PDF
            presentation.ExportToPdf(new FileStream(@"..\..\..\data\exported-document.pdf", FileMode.Create));
        }
    }
    

    Implements

    Inheritance

    Object
    Presentation
    See Also