I have a NET 8 Blazor Server App running on a nginx reverse proxy server. I have PDFSharp installed and have a printing function created to print out a sheet. I tested this on my local machine and it works there. But when I deploy my app and print from the server, the print fails.
Here is the console error.
Error: System.NullReferenceException: Object reference not set to an instance of an object. at PdfSharp.Fonts.OpenType.OpenTypeFontFace.CetOrCreateFrom(XFontSource fontSource) at PdfSharp.Drawing.XGlyphTypeface..ctor(String key, XFontFamily fontFamily, XFontSource fontSource, XStyleSimulations styleSimulations) at PdfSharp.Drawing.XGlyphTypeface.GetOrCreateFrom(String familyName, FontResolvingOptions fontResolvingOptions) at PdfSharp.Drawing.XFont.Initialize() at PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyleEx style, XPdfFontOptions pdfOptions) at PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyleEx style) at AutoHARP3HarpFantasy.Data.Classes.pCharStat.PrintCharacter() in /var/www/autoharponline/Data/Classes/pCharStat.cs:line 1220 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
and this is what line 1220 has
gfx.DrawString("Name:", new XFont(fontName, 20, XFontStyleEx.Bold), XBrushes.Black, 25, 20, XStringFormats.TopLeft); It seems to be complaining about new XFont(fontName, 20, XFontStyleEx.Bold).
To give more context here the code around this line
try { gfx.DrawString("Name:", new XFont(fontName, 20, XFontStyleEx.Bold), XBrushes.Black, 25, 20, XStringFormats.TopLeft); } catch(Exception e) { fontName = "arial"; gfx.DrawString("Name:", new XFont(fontName, 20, XFontStyleEx.Bold), XBrushes.Black, 25, 20, XStringFormats.TopLeft); }
Just to see if perhaps I misspelled the font for Arial I changed it to Uppercase "Arial" and tested. That didn't fix it. So I am at a loss as to what the error is telling me about this call. I have other gfx calls before this so gfx should not be null here.
|