Reporting - Enhanced Drawing Engine for Linux and MacOS (v20.1)

Reporting Team Blog
27 July 2020

As you may already know, we added .NET Core support to DevExpress Reports two years ago (v18.1). One of the decisions we made was to stay with GDI+. As such, our .NET Core implementation for Linux and MacOS relied on the System.Drawing.Common package that was based on an open-source library called libgdiplus.

The upside of libgdiplus is that it uses the same API as Windows GDI+. The downside is that libgdiplus measures strings and draws images differently than does Windows. Since it’s an open-source library and does not have official support from Microsoft, libgdiplus has not progressed as we’d have liked.

Quick Note: We encourage you to use the latest version of libgdiplus if you are using DevExpress Reports/.NET Core. The package manager still downloads an older build – so be sure to verify build information before you deliver your application to end-users.

The Path Forward

Based on internal testing and customer feedback, we know that Linux / MacOS rendering is not what it ought to be. We’ve addressed as many issues as possible at the DevExpress component level, and done our best not to touch drawing engine code.

One solution to the rendering problem was to use a third-party library called pango. This path led to a new measurement and drawing engine – one that replaced our standard implementation. To avoid direct open-source library dependencies, we released this new drawing engine as a separate NuGet package that must be installed manually.

The new engine improves results (we’ve blogged about this previously) when reports are exported to image or PDF format on Linux:

Proper text measurement and word wrapping

libgdiplus Cross-Platform Drawing Engine

International character set support

libgdiplus Cross-Platform Drawing Engine

Correctly applied text style

libgdiplus Cross-Platform Drawing Engine

Proper text alignment (justify)

libgdiplus Cross-Platform Drawing Engine

How to use the DevExpress Cross-Platform Drawing Engine in Your Application

If you’re ready to use this updated rendering engine in your .NET Core app, you should:

  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:
  2.  dotnet add package runtime.osx.10.10-x64.CoreCompat.System.Drawing
  3. Install homebrew.
  4. Install additional operating system libraries:
  5. brew install mono-libgdiplus  
    brew install pango
    

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 assemblies are located in the vcpkg repository’s installed subfolder.

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

The code below registers the drawing engine in an ASP.NET Core appplication if it 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.

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

Once you perform these steps, your application will be ready to go. It will use our updated cross-platform drawing engine to print/export reports, and to display them within the Document Viewer. You can download a complete sample project from the following GitHub repository to learn more: Reporting - Use the DevExpress Cross-Platform Drawing Engine.

Recommendations

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

  2. If you go with libgdiplus, use the latest version (v6 at the time of writing) of the library to avoid glitches like this:

You can build the library from source code, but this may introduce instability. See the Download page for additional details.

Your Feedback Matters

As always, we welcome any feedback. Feel free to post comments below and let us know your experience with this enhanced drawing engine.

Tell us about your development environment and how you use DevExpress Reports within your organization:

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.