Articles in this section
Category / Section

How to create a PowerPoint file in UWP?

9 mins read

Syncfusion Essential PowerPoint is a .NET PowerPoint library used to create, read, and edit PowerPoint documents. Using this library, you can start creating a PowerPoint document in UWP.

Steps to create PowerPoint file programmatically:

 

  1. Create a new C# Blank App (Universal Windows) project.

 

  1. Install the Syncfusion.Presentation.UWP NuGet package as reference to your .NET Framework applications from NuGet.org.

 

 

  1. Add a new button in the MainPage.xaml as shown below.

 

<Page
   x:Class="CreatePresentationSample.MainPage"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="using:CreatePresentationSample"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d">
 
   <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
         <Button x:Name="button" Content="Create Document" Click="OnButtonClicked" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
 
</Page>

 

  1. Include the following namespaces in the Mainpage.xamal.cs file.

 

using Syncfusion.Presentation;
using Windows.Storage.Pickers;
using Windows.Storage;

 

Imports Syncfusion.Presentation
Imports Windows.Storage.Pickers
Imports Windows.Storage

 

  1. Include the below code snippet in the click event of the button in MainPage.xaml.cs, to create a PowerPoint file and save the PowerPoint document as a physical file and open the file for viewing.

C#:

//create a new PowerPoint presentation.
using (IPresentation pptxDoc = Presentation.Create())
{
    // Adds a blank slide to the Presentation
    ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
 
    //Add a textbox to the slide
    IShape shape = slide.AddTextBox(10, 10, 500, 100);
 
    //Add a text to the textbox.
    shape.TextBody.AddParagraph("Hello World!!!");
 
    //Initializes FileSavePicker
    FileSavePicker savePicker = new FileSavePicker();
    savePicker.SuggestedStartLocation = PickerLocationId.Desktop;
    savePicker.SuggestedFileName = "Sample";
    savePicker.FileTypeChoices.Add("PowerPoint Files", new List<string>() { ".pptx" });
 
    //Creates a storage file from FileSavePicker
    StorageFile storageFile = await savePicker.PickSaveFileAsync();
    
    //Saves changes to the specified storage file
    await pptxDoc.SaveAsync(storageFile);
 
    // Launch the saved file
    await Windows.System.Launcher.LaunchFileAsync(storageFile);
}

 

VB.Net:

    'Creates a PowerPoint instance.
    Dim pptxDoc As IPresentation = Presentation.Create()
 
    'Adds a slide to the PowerPoint presentation.
    Dim slide As ISlide = pptxDoc.Slides.Add(SlideLayoutType.Blank)
 
    'Add a textbox to the slide.
    Dim shape As IShape = slide.AddTextBox(10, 10, 500, 100)
 
    'Add a text to the textbox.
    shape.TextBody.AddParagraph("Hello World!!!")
  
    'Initializes FileSavePicker
    Dim savePicker As New FileSavePicker()
    savePicker.SuggestedStartLocation = PickerLocationId.Desktop
    savePicker.SuggestedFileName = "Sample"
    savePicker.FileTypeChoices.Add("PowerPoint Files", New List(Of String)() From {".pptx"})
    Dim storageFile As StorageFile = Await savePicker.PickSaveFileAsync()
    Await pptxDoc.SaveAsync(storageFile)

 

A complete working example to create PowerPoint file in UWP can be downloaded from Create-PowerPoint-file.zip.

By executing the program, you will get the PowerPoint file as follows.

 

Take a moment to peruse the documentation, where you can find basic slide manipulation options Working with slides, adding Charts in slide, organizing and analyzing data through Tables, and most importantly Image conversions etc., with code examples.

Refer here to explore the rich set of Syncfusion Essential PowerPoint features.

An online sample link to generate PowerPoint file.

See Also:

Create a PowerPoint file in ASP.NET MVC

Create a PowerPoint file in ASP.NET

Create a PowerPoint file in Windows Forms

Create a PowerPoint file in Xamarin

Create a PowerPoint file in WPF

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied