c# - Error accessing Fonts in Azure Web App when using PDFSharp -
i using pdfsharp dynamically generate pdf's in web app. web app works fine locally however, when push app azure (as web app), following exception:
{"message":"an error has occurred.","exceptionmessage":"internal error. font data not retrieved.","exceptiontype":"system.invalidoperationexception","stacktrace":" @ pdfsharp.fonts.opentype.fontdata.creategdifontimage(xfont font, xpdffontoptions options)\r\n @ pdfsharp.fonts.opentype.fontdata..ctor(xfont font, xpdffontoptions options)\r\n @ pdfsharp.fonts.opentype.opentypedescriptor..ctor(xfont font, xpdffontoptions options)\r\n @ pdfsharp.fonts.opentype.opentypedescriptor..ctor(xfont font)\r\n @ pdfsharp.fonts.fontdescriptorstock.createdescriptor(xfont font)\r\n @ pdfsharp.drawing.xfont.get_metrics()\r\n @ pdfsharp.drawing.xfont.initialize()\r\n @ pdfsharp.drawing.xfont..ctor(string familyname, double emsize)\r\n @ spiro.services.orderservice.getorderlabel(int32 id, nullable`1 quantity)\r\n @ spiro.web.controllers.webapi.v1.ordercontroller.getorderlabel(int32 id, nullable`1 quantity)\r\n @ lambda_method(closure , object , object[] )\r\n @ system.web.http.controllers.reflectedhttpactiondescriptor.actionexecutor.<>c__displayclass10.b__9(object instance, object[] methodparameters)\r\n @ system.web.http.controllers.reflectedhttpactiondescriptor.actionexecutor.execute(object instance, object[] arguments)\r\n @ system.web.http.controllers.reflectedhttpactiondescriptor.executeasync(httpcontrollercontext controllercontext, idictionary`2 arguments, cancellationtoken cancellationtoken)\r\n--- end of stack trace previous location exception thrown ---\r\n @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)\r\n @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)\r\n @ system.web.http.controllers.apicontrolleractioninvoker.d__0.movenext()\r\n--- end of stack trace previous location exception thrown ---\r\n @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)\r\n @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)\r\n @ system.web.http.controllers.actionfilterresult.d__2.movenext()\r\n--- end of stack trace previous location exception thrown ---\r\n @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)\r\n @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)\r\n @ system.web.http.controllers.authenticationfilterresult.d__0.movenext()\r\n--- end of stack trace previous location exception thrown ---\r\n @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)\r\n @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task)\r\n @ system.web.http.dispatcher.httpcontrollerdispatcher.d__1.movenext()"}
i create text follows:
var document = new pdfdocument(); var page = document.addpage(); var gfx = xgraphics.frompdfpage(page); var font = new xfont("calibri", 30); gfx.drawstring(rows[i], font, xbrushes.black, new xpoint(xunit.frommillimeter(10), xunit.frommillimeter(10)), xstringformats.topleft);
i can see azure server has bunch of fonts installed - i'm stuck problem is... thank in advance.
azure app service (aka azure websites) enforces number of more restrictive security constraints cloud service or iaas (vms). 1 of things blocked access of gdi api surface area, includes font manipulation. other folks have noted, if same code works on plain iaas vm, cloud service, or local desktop/laptop, problem running hard block on underlying gdi calls.
Comments
Post a Comment