Add PdfSharp font resolver for .NET 8 compatibility

Added a `PdfSharpFontResolver` class to enable font resolution
for PdfSharp in .NET 8, addressing the lack of system font
access. The resolver reads fonts from the Windows Fonts folder
and supports the Arial font family. Registered the resolver
globally in `Program.cs` using `GlobalFontSettings.FontResolver`.

Updated `Program.cs` with comments explaining the necessity of
the resolver for .NET 8. The resolver includes methods to map
font family names to specific font files and load font data.
Throws a `FileNotFoundException` if required fonts are missing.

Made minor formatting changes in `Program.cs` without altering
the `SwaggerDoc` description functionality.
This commit is contained in:
2026-07-01 01:25:24 +02:00
parent 01fc29f59e
commit 49ec9fbead
2 changed files with 51 additions and 1 deletions

View File

@@ -104,7 +104,7 @@ try
{
Version = "v1",
Title = "signFLOW Absender-API",
Description = "Eine API zur Verwaltung der Erstellung, des Versands und der Nachverfolgung von Umschlägen in der signFLOW-Anwendung.",
Description = "Eine API zur Verwaltung der Erstellung, des Versands und der Nachverfolgung von Umschl<EFBFBD>gen in der signFLOW-Anwendung.",
Contact = new OpenApiContact
{
Name = "Digital Data GmbH",
@@ -338,6 +338,10 @@ try
builder.Services.AddDevExpressBlazor();
builder.Services.AddDevExpressServerSideBlazorPdfViewer();
// PdfSharp font resolver — required for .NET 8 (no system font access without it)
PdfSharp.Fonts.GlobalFontSettings.FontResolver =
EnvelopeGenerator.Server.Services.PdfSharpFontResolver.Instance;
// Configuration Options
builder.Services.Configure<EnvelopeGenerator.Server.Client.Options.ApiOptions>(
builder.Configuration.GetSection("ApiOptions"));