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.