reportviewercore icon indicating copy to clipboard operation
reportviewercore copied to clipboard

PDF rendering in Linux

Open lkosson opened this issue 2 years ago • 0 comments

TLDR: No native support for exporting RDLC to PDF under Linux. Use Wine for a workaround.

Reporting services uses Uniscribe to measure fonts when laying out PDF. Uniscribe libraries are loaded via P/Invoke and are provided only for Windows platform. This causes any attempts to directly use this package to render PDFs when deployed to linux server to end with error mentioning missing usp10.dll shared library.

Preliminary experiments show that effort required to port PDF exporter to use some other method/library for laying out text is comparable to completely rewriting the exporter using other available cross-platform PDF library, such as QuestPDF (iText is out of scope due to its license). Either task is well beyond what I can provide, as this whole project is still non-profit one-man job.

Moreover, with .NET 6 Microsoft is sunsetting GDI support for non-windows platforms, further increasing complexity and scope of porting required to get PDFs working in Linux.

On the bright side, Wine project provides linux implementations of many Win32-specific libraries. As of Wine version 5.0, Uniscribe implementation is mature enough to support all the functions required by Reporting Services. This means you can use it as a workaround for rendering your reports to PDFs. The workaround is a bit clunky and goes like this:

  • Install Wine 5.0 or newer. For Debian Bullseye or Bookworm, apt install wine will do.
  • Download Windows version of .NET runtime binaries from https://dotnet.microsoft.com/en-us/download/dotnet - e.g. https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-3.1.30-windows-x86-binaries.
  • Extract/install those binaries to some local folder, e.g. ~/dotnet-3.1-windows.
  • Start your application using 64-bit version of Wine and Windows version of .NET, e.g. wine64 ~/dotnet-3.1-windows/dotnet.exe YourApplication.dll.

If your application crashes with unsupported flags 00000020 somewhere inside bcrypt, make sure you have proper version of Wine installed. Wine 4.1 provided in Debian Buster and earlier won't work.

lkosson avatar Jun 19 '23 10:06 lkosson