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

Use the DevExpress Cross-Platform Drawing Engine

  • 3 minutes to read

This topic describes how to replace the libdgiplus-based drawing engine with the DevExpress cross-platform drawing engine in your ASP.NET Core application. A drawing engine is invoked when users preview, print, or export reports. Based on tests conducted on Linux and MacOS, the cross-platform engine renders reports more accurately. The following improvements are seen, for instance, when users export reports to image and PDF on Linux:

  • Fully displayed text

    libgdiplus Cross-platform drawing engine
  • International character set support

    libgdiplus Cross-platform drawing engine
  • Correctly applied text emphasis

    libgdiplus Cross-platform drawing engine
  • Proper text alignment

    libgdiplus Cross-platform drawing engine

Follow the steps below to enable the cross-platform drawing engine for your reports:

  1. Add the DevExpress.CrossPlatform.Printing.DrawingEngine NuGet package to your ASP.NET Core application.

    dotnet add package DevExpress.CrossPlatform.Printing.DrawingEngine
    
  2. Configure the environment.

    Debian Linux

    Install the following operating system libraries:

    sudo apt-get update  
    sudo apt-get install -y software-properties-common  
    sudo add-apt-repository 'deb http://deb.debian.org/debian bullseye main'  
    sudo apt-get update 
    sudo apt-get install -y libc6 -f -o APT::Immediate-Configure=0 
    sudo apt-get install -y libgdiplus
    sudo apt-get install -y libicu-dev
    sudo apt-get install -y libharfbuzz0b
    sudo apt-get install -y libfontconfig1
    sudo apt-get install -y libfreetype6
    sudo apt-get install -y libpango-1.0-0
    sudo apt-get install -y libpangocairo-1.0 
    
    MacOS
    1. Add the runtime.osx.10.10-x64.CoreCompat.System.Drawing NuGet package to your ASP.NET Core application:
     dotnet add package runtime.osx.10.10-x64.CoreCompat.System.Drawing
    
    1. Install homebrew.
    2. Install additional operating system libraries:
    brew install mono-libgdiplus  
    brew install pango
    

    You may want to modify the formulae to install the recommended versions pango-1.48.0 and cairo-1.16.0_3.

    Windows

    Use vcpkg to install DLLs. Run the Admin Command Prompt and execute the following commands:

    git clone https://github.com/microsoft/vcpkg.git
    cd vcpkg
    .\bootstrap-vcpkg.bat
    vcpkg.exe integrate install
    vcpkg.exe install pango --triplet x86-windows
    vcpkg.exe install pango --triplet x64-windows
    

    The DLLs are located in the vcpkg repository’s installed subfolder.

  3. Register the cross-platform drawing engine at application startup.

    The code below registers the drawing engine if the application is executed on a non-Windows platform. The engine does not need to be registered on Windows because reports are rendered without the issues described above.

    using System.Runtime.InteropServices;
    
    public void ConfigureServices(IServiceCollection services) {
        // ...
        if(!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
            DevExpress.Printing.CrossPlatform.CustomEngineHelper.RegisterCustomDrawingEngine(
                typeof(
                    DevExpress.CrossPlatform.Printing.DrawingEngine.PangoCrossPlatformEngine
                ));
        }
    }
    

The application is ready. It uses the cross-platform drawing engine to print and export reports, and to display them in the Document Viewer.

View Example: How to Use the DevExpress CrossPlatform Drawing Engine in an ASP.NET Core Application

Note

All fonts used in the report should be available on the server that hosts the report. Please do install all fonts on the server.