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.
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:
Add the DevExpress.CrossPlatform.Printing.DrawingEngine NuGet package to your ASP.NET Core application.
dotnet add package DevExpress.CrossPlatform.Printing.DrawingEngine
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
- Install homebrew.
- 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.
- 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
All fonts used in the report should be available on the server that hosts the report. Please do install all fonts on the server.
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: