Create PowerPoint (PPTX) or PDF file on Azure
GemBox.Presentation is a standalone .NET component that's ideal for web applications because of its fast performance and thread safety when working with multiple PresentationDocument
objects.
GemBox.Presentation can be used on various platforms including Azure Functions and Azure App Services. To create an Azure function, search for "Azure Functions" in a new project dialog. To avoid any potential issues with GemBox.Presentation, we recommend using the newer versions of Azure Functions (v3 or above). The following is an Azure function project file: Note that saving to XPS and image formats (like PNG and JPG) currently works only on Azure Functions that target .NET Framework. The following example shows how you can create a PowerPoint presentation using GemBox.Presentation in an Azure Function. App Service is a fully managed platform for building, deploying and scaling web apps. GemBox.Presentation can be used from applications that run on an App Service. To build an ASP.NET Core application, check out our ASP.NET Core example. To publish an application to Azure App service you need to: 1. Pick Azure as publish target. 2. Pick Azure App Service as a specific target. 3. Specify existing App Service or create a new one. You can use the full functionality of GemBox.Presentation on Azure Virtual Machine, Azure Cloud Services, and Azure Functions. But for App Services, there are few rendering limitations: These features currently have WPF dependencies which means they require a .NET Windows Desktop Runtime. However, we do have plans for providing cross-platform support for them in future releases.Azure Functions
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
<PackageReference Include="GemBox.Presentation" Version="*" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using GemBox.Presentation;
public static class GemBoxFunction
{
[FunctionName("GemBoxFunction")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
ILogger log)
{
// If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
var presentation = new PresentationDocument();
var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);
var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 5, 4, LengthUnit.Centimeter);
var paragraph = textBox.AddParagraph();
paragraph.AddRun("Hello World!");
var fileName = "Output.pptx";
var options = SaveOptions.Pptx;
using (var stream = new MemoryStream())
{
presentation.Save(stream, options);
return new FileContentResult(stream.ToArray(), options.ContentType) { FileDownloadName = fileName };
}
}
}
Imports System.IO
Imports Microsoft.AspNetCore.Mvc
Imports Microsoft.Azure.WebJobs
Imports Microsoft.Azure.WebJobs.Extensions.Http
Imports Microsoft.AspNetCore.Http
Imports Microsoft.Extensions.Logging
Imports GemBox.Presentation
Module GemBoxFunction
<FunctionName("GemBoxFunction")>
Async Function Run(
<HttpTrigger(AuthorizationLevel.Anonymous, "get", Route := Nothing)> req As HttpRequest,
log As ILogger) as Task(Of IActionResult)
' If using the Professional version, put your serial key below.
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
Dim presentation As New PresentationDocument()
Dim slide = presentation.Slides.AddNew(SlideLayoutType.Custom)
Dim textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 5, 4, LengthUnit.Centimeter)
Dim paragraph = textBox.AddParagraph()
paragraph.AddRun("Hello World!")
Dim fileName = "Output.pptx"
Dim options = SaveOptions.Pptx
Using stream As New MemoryStream()
presentation.Save(stream, options)
Return New FileContentResult(stream.ToArray(), options.ContentType) With { .FileDownloadName = fileName }
End Using
End Function
End Module
Azure App Services
Limitations on App Services
ConvertToImageSource
and ConvertToXpsDocument
methods.