Skip to main content

Use Office File API on macOS

  • 3 minutes to read

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


Add Common Libraries

  • The .NET library of the required version.

  • Optional. If your application needs to render JPEG images within PDF files, install the following package:

    brew install jpeg-turbo

Add Drawing Engine Libraries

Add libraries related to the drawing engine to your application. The Office File API can use the following two drawing engines. Note that each engine is compatible with a certain range of System.Drawing.Common library versions.

Drawing Engine System.Drawing.Common version
libgdiplus-based Drawing Engine 6 and earlier
SkiaSharp-based Drawing Library All versions

How Office File API Chooses an Engine

The Office File API looks for drawing library references and enables the corresponding engine. The choice is also restricted by System.Drawing.Common library compatibility, as outlined in the table above. If the application contains references for both engines (that is, libgdiplus and DevExpress.Drawing.Skia), the libgdiplus-based engine is used. If no references are available, an exception is thrown.

Refer to the following article for more information on the drawing engines: DevExpress.Drawing Graphics Library

Libgdiplus-Based Drawing Engine

In addition to the libraries listed above, the libgdiplus-based drawing engine requires the following packages:

SkiaSharp-Based Drawing Engine

Make sure that you add the DevExpress.Drawing.Skia package to your application to use the SkiaSharp-Based drawing engine.

If you use the the System.Drawing.Common package v7 and later, the Skia-based engine is enabled automatically and the libgdiplus library is not required.

Create the Application

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

Click ViewTerminal in the main menu to open the integrated terminal.

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.

Add DevExpress.Document.Processor Package

Obtain your NuGet Feed URL and install the DevExpress.Document.Processor NuGet package as described in the following topic: Use NuGet Packages to Install Office File API Components.

Add the DevExpress.Pdf.SkiaRenderer package to enable rendering of PDF page content within your app.


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

Insert Code

Paste the code below in the Main method of the Program.cs file (or Program.vb file’s Main procedure for Visual Basic). The following example converts a DOCX file to PDF:

using DevExpress.XtraRichEdit;
// ...

static void Main(string[] args) {
    using (var 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 following image illustrates the result. This tutorial uses Visual Studio Code.