Create Word (DOCX) or PDF file on Azure

GemBox.Document provides support for .NET Standard 2.0, a cross-platform specification of .NET APIs, which is why it can be used on various platforms including Azure functions and Azure App Services.

Azure Functions

To create an Azure function, search for "Azure Functions" in a new project dialog.

Screenshot of Visual Studio project type selection
Screenshot of Visual Studio project type selection

To avoid any potential issues with GemBox.Document, we recommend using the newest version of Azure Functions (v3).

The following example shows how you can create a Word document using GemBox.Document in an Azure function.

Generated Word document (DOCX format) from Azure Functions
Screenshot of Word file created with Azure function
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.Document;

public static class GemBoxFunction
{
    [FunctionName("GemBoxFunction")]
    public static async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
        ILogger log)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = new DocumentModel();

        Section section = new Section(document);
        document.Sections.Add(section);

        Paragraph paragraph = new Paragraph(document);
        section.Blocks.Add(paragraph);

        Run run = new Run(document, "Hello World!");
        paragraph.Inlines.Add(run);

        var fileName = "Output.docx";
        var options = SaveOptions.DocxDefault;

        using (var stream = new MemoryStream())
        {
            document.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.Document

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 Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As New DocumentModel()

        Dim section As New Section(document)
        document.Sections.Add(section)

        Dim paragraph As New Paragraph(document)
        section.Blocks.Add(paragraph)

        Dim inline As New Run(document, "Hello World!")
        paragraph.Inlines.Add(inline)

        Dim fileName = "Output.docx"
        Dim options = SaveOptions.DocxDefault

        Using stream As New MemoryStream()
            document.Save(stream, options)
            Return New FileContentResult(stream.ToArray(), options.ContentType) With { .FileDownloadName = fileName }
        End Using

    End Function
End Module

Azure App Services

App Service is a fully managed platform for building, deploying and scaling web apps. GemBox.Document 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.

Screenshot of Visual Studio target selection
Screenshot of Visual Studio target selection

2. Pick Azure App Service as a specific target.

Screenshot of Visual Studio specific target selection
Screenshot of Visual Studio specific target selection

3. Specify existing App Service or create a new one.

Screenshot of Visual Studio specific App Service selection
Screenshot of Visual Studio specific App Service selection

Limitations on Azure Functions and App Services

The .NET Standard version of GemBox.Document has full functionality of .NET Framework version, but with few rendering limitations (unsupported features):

There are no limitations when using GemBox.Document on Windows on Azure Virtual Machine or Azure Cloud Services.

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Document yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.