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 sid main'  
sudo apt-get update  
sudo apt-get install libgdiplus
sudo apt-get install libicu-dev libharfbuzz0b libfontconfig1 libfreetype6
sudo apt-get install libpango-1.0-0
sudo apt-get install libpangocairo-1.0

MacOS

  1. Install homebrew.
  2. Install additional operating system libraries.
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:

Showcase Your Apps on DevExpress.com

Highlight your business app and share your development experiences with the DevExpress community. To include your app in our upcoming App Showcase, please forward an application screenshot to clientservices@devexpress.com and tell us which DevExpress products you currently use within your organization.
2 comment(s)
J Horv
J Horv
The survey asks what OS and IDE I currently use, but I want to tell you what I'd like to use.  I use Windows + Visual Studio because that's what the dev tools run on, but I would use macOS and Visual Studio for Mac for all my development if I could.
31 July 2020
jdubeau
jdubeau
Hi Dmitry,

I do enjoy working on my ubuntu 20.04 laptop. Golang, python, react.js, and kubernetes.
I have alot desktop software loaded on it as well. I would like to use Devexpress on linux.
But, I'm just not sure about it. Reports are important for business applications.
I glad you are working on it.
25 August 2020

Please login or register to post comments.