All docs
V20.1
20.1
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Use Office File API on macOS (.NET Core)

  • 2 minutes to read

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

Prerequisites

  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 Homebrew package manager to your system and use the following terminal command to install the latest libgdiplus version and the library dependencies:

    brew install freetype harfbuzz fontconfig mono-libgdiplus

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.

    # The -s key specifies the package source (DevExpress NuGet feed)
    dotnet add package DevExpress.Document.Processor -s https://nuget.devexpress.com/{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.
            documentProcessor.ExportToPdf("PdfDocument.pdf");
        }
    }
    

Run the Application

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

dotnet run

The image below shows the result.

Office_Getting_Started_On-macOS_Result