I removed this code and run application from Visual Studio IDE in Windows 11. It throws error
System.InvalidOperationException
HResult=0x80131509
Message=No appropriate font found for family name 'Calibri'. Implement IFontResolver and assign to 'GlobalFontSettings.FontResolver' to use fonts. See
https://docs.pdfsharp.net/link/font-resolving.html Source=PdfSharp
StackTrace:
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 MigraDoc.DocumentObjectModel.TextMeasurement.Realize() in C:\raamat\eevaweb\Store\Reporting\VFPConverter\Class.cs:line 154
at MigraDoc.DocumentObjectModel.TextMeasurement.MeasureString(String text, UnitType unitType) in C:\raamat\eevaweb\Store\Reporting\VFPConverter\Class.cs:line 74
at MigraDoc.DocumentObjectModel.TextMeasurement.MeasureString(String text) in C:\raamat\eevaweb\Store\Reporting\VFPConverter\Class.cs:line 114
...
Windows has Calibri font installed. Using NewFontresolver() it worked in Windows and Linux.
If it is not possible to use Calibri, some other font can used so that pdf is created.
How to force PDFSharp to silently use Calibri or some other font without throwing error?