I try to get PdfSharp working in an Azure Function But I have some problems with fonts
// Create a new PDF document
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
// Create an empty page
PdfPage page = document.AddPage();
// Get an XGraphics object for drawing
XGraphics gfx = XGraphics.FromPdfPage(page);
// Create a font
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
// Draw the text
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
This is also the code from the PDFSharp sample page... At the font line he gives me the following error...
Exception while executing function: Functions.PDFGenerationFunction. PdfSharp: Internal error. Font data could not retrieved.
Do I need to reference something special? Or is it just not possible to do this in an Azure function?
PDFSharp version --> "PDFsharp" : "1.32.3057"
And/Or another solution to generate a PDF document in an Azure Function...
This is likely an issue with the sandbox that Azure Functions and webapps run in. Check out this list for known PDF libraries that will work in the sandbox. https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With