I have a problem with PrintDocument from System.Drawing.Common when I use this on Linux, to be more specific, the problem comes from PrintingServices.LoadPrinterSettings, which is using in PrinterSettings.Unix
here the content of the error:
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request. System.NullReferenceException: Object reference not set to an instance of an object. at System.Drawing.Printing.PrintingServices.LoadPrinterSettings(String printer, PrinterSettings settings)
On Windows everything working correctly, because PrintDocument uses solution prepare for Windows.
Code:
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = printerName;
pd.OriginAtMargins = true;
pd.DefaultPageSettings.Landscape = true;
pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
pd.PrintPage += new PrintPageEventHandler(Pd_PrintPage);
pd.Print();
I'm using:
System.Drawing.common (4.5.1)
.NET Core 2.1
libc6-dev and libgdiplus have been installed on Linux
Linux - Debian 9
Anyone can help?