Skip to main content
A newer version of this page is available. .

Use Office File API on Linux (.NET Core)

  • 3 minutes to read

This tutorial describes how to create a simple Office File API application for .NET Core on Linux.


  1. .NET Core SDK 2.1 or later.

  2. A code editor. This tutorial uses Visual Studio Code.

  3. Libgdiplus library. This library is required to use the System.Drawing functionality in Office File API applications.

    Add the Mono repository to your system to install the latest libgdiplus version or use the following terminal commands (depending on your Linux distribution):



    Debian / Ubuntu

    sudo apt install -y libgdiplus libc6 libc6-dev

    CentOS 7 / CentOS 8 /

    Red Hat Enterprise Linux /

    Fedora 29 / Fedora 30

    sudo yum install -y libgdiplus glibc glibc-devel

    openSUSE 15.1

    sudo zypper install -y glibc glibc-devel libgdiplus0


    You can also install the ttf-mscorefonts-installer package to add Microsoft TrueType core fonts (Arial, Times New Roman, Courier New, etc.) to your system. Run the following terminal command to install this package in Debian / Ubuntu and accept the license agreement:

    sudo apt-get install ttf-mscorefonts-installer

  4. (Optional) If your Office File API application throws the DllNotFoundException, use the commands below to install the missing dependencies:



    Debian / Ubuntu

    sudo apt install -y fontconfig libharfbuzz0b libfreetype6

    CentOS 7 / CentOS 8 /

    Red Hat Enterprise Linux /

    Fedora 29 / Fedora 30

    sudo yum install -y libicu fontconfig harfbuzz freetype

    openSUSE 15.1

    sudo zypper install -y libicu fontconfig libharfbuzz0 freetype

Create the Application

  1. Create a folder for you project (OfficeConsoleApp in this example) and open it in Visual Studio Code.

  2. Click View -> Terminal in Visual Studio Code’s main menu to open the integrated terminal.

  3. Use the dotnet new command to create a new console application.

    dotnet new console

    This command adds the following files to your folder:

    • OfficeConsoleApp.csproj / OfficeConsoleApp.vbproj

    • Program.cs / Program.vb.

  4. Obtain your NuGet feed URL and install the DevExpress.Document.Processor NuGet package.


    You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this package in production code.

    # The -s key specifies the package source (DevExpress NuGet feed)
    dotnet add package DevExpress.Document.Processor -s{your-feed-authorization-key}/api
  5. Paste the code below in the Main method of the Program.cs file (or Program.vb file’s Main procedure for Visual Basic). This example shows how to convert a DOCX file to PDF.

    using DevExpress.XtraRichEdit;
    // ...
    static void Main(string[] args)
        using (RichEditDocumentServer documentProcessor =
            new RichEditDocumentServer())
            // Load a document from a file.
            documentProcessor.LoadDocument("Document.docx", DocumentFormat.OpenXml);
            // Export the document to PDF.

Run the Application

Type dotnet run in the terminal window to run the program.

dotnet run

The image below shows the result.