79836907

Date: 2025-12-03 12:58:13
Score: 9.5 🚩
Natty:
Report link

Did you manage to resolve the issue?

I have the exact same problem in slightly different conditions - I use Azure Functions instead of AWS.

I generate a PDF from SVG like that:

var pdfBytes = Document.Create(container =>
{
    container.Page(page =>
    {
        page.Size(PageSizes.A4);
        page.Content().Svg(svgContent);
    });
}).GeneratePdf();

When I run this code locally on my Windows machine - everything displays as expected. When I do it inside a Linux container - again, all the text is there, but in a different font. And when I deploy my app to Azure - everything renders, apart from the text. Images and tables are there, but not a single letter is present.

Therefore, I suspect it may be matter of fonts. Probably none are available in the cloud container (not even a fall-back one) and that's why the text cannot render. But how can I resolve it?

I tried including fonts in my project and registering them in runtime, as suggested in QuestPDF documentation, like that:

private static void AddFonts()
{
    try
    {
        var fontsDir = Path.Combine(AppContext.BaseDirectory, "Resources", "Fonts");

        using (var juraStream = File.OpenRead(Path.Combine(fontsDir, "Jura.ttf")))
        {
            FontManager.RegisterFontWithCustomName("Jura", juraStream);
        }

        using (var interItalicStream = File.OpenRead(Path.Combine(fontsDir, "Inter-Italic.ttf")))
        {
            FontManager.RegisterFontWithCustomName("Inter", interItalicStream);
        }

        Console.WriteLine("Fonts registered successfully via streams: Jura, Inter-Italic");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error registering fonts: {ex.Message}");
        throw;
    }
}

I tried to do it both on startup and just before PDF generation. I used all available font registration methods (RegisterFont, RegisterFontWithCustomName and RegisterFontFromEmbeddedResource). Registration seems to succeed, but nothing changes. Every time the result is the same - text renders when ran on local machine or in Docker container, but not in the Azure cloud resource.

Reasons:
  • Blacklisted phrase (0.5): how can I
  • RegEx Blacklisted phrase (3): Did you manage to resolve the
  • RegEx Blacklisted phrase (1.5): resolve the issue?
  • RegEx Blacklisted phrase (1.5): how can I resolve it?
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): I have the exact same problem
  • Contains question mark (0.5):
  • Starts with a question (0.5): Did you
  • Low reputation (1):
Posted by: Laurer