Back to Devexpress

Use Office File API on Linux

officefileapi-401441-installation-guide-use-office-file-api-on-linux.md

latest4.2 KB
Original Source

Use Office File API on Linux

  • Dec 24, 2025
  • 3 minutes to read

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

Prerequisites

Add Common Libraries

  • The .NET library of the required version.

  • The font libraries below (based on your Linux distribution) to measure, render, and export document text to PDF within your Office File API application.

  • Packaged fonts. To install font files on your machine, put them in the /usr/share/fonts folder and execute the ‘fc-cache’ command to update fontconfig cache files.

  • If your application needs to render JPEG images within PDF files, install the packages below based on your Linux distribution (or any other packages that implement libjpeg API v6.2 or v8.0):

Add Drawing Engine Libraries

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. Refer to the following article for more information on the drawing engines: DevExpress.Drawing Graphics Library

Create an 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.

cli
dotnet new console
cli
dotnet new console -lang VB

This command adds the following files to your folder:

  • OfficeConsoleApp.csproj / OfficeConsoleApp.vbproj

  • Program.cs / Program.vb.

Add DevExpress.Document.Processor Package

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.

Important

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 the Program.vb file’s Main procedure for Visual Basic). The following example converts a DOCX file to PDF:

csharp
using DevExpress.XtraRichEdit;
// ...

static void Main(string[] args) {
    using (var wordProcessor =
        new RichEditDocumentServer()) {
        // Load a document from a file.
        wordProcessor.LoadDocument("Document.docx", DocumentFormat.Docx);
        // Export the document to PDF.
        wordProcessor.ExportToPdf("PdfDocument.pdf");
    }
}
vb
Imports DevExpress.XtraRichEdit
' ...

Sub Main(args As String())
    Using wordProcessor As RichEditDocumentServer = New RichEditDocumentServer()
        ' Load a document from a file.
        wordProcessor.LoadDocument("Document.docx", DocumentFormat.Docx)
        ' Export the document to PDF.
        wordProcessor.ExportToPdf("PdfDocument.pdf")
    End Using
End Sub

Run the Application

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

cli
dotnet run

The following image illustrates the result. This tutorial uses Visual Studio Code.