I am using spire lib to create pdf files for the user.
string userId = User.Identity.GetUserId();
User trainee = _userDAL.GetUserByIdentityId(userId);
// Get the Employee scores
string fileNameTemplate = Server.MapPath(Url.Content("~/assets/cert1-{0}-{1}.docx"));
string nnn = string.Format("cert1-{0}-{1}.pdf", trainee.StaffID, DateTime.Now.Millisecond);
string serverPath = MainConfig.P_EXPORT;
var folder = Server.MapPath(serverPath);
using (Document document_test = new Document()) { document_test.LoadFromFile(fileNameTemplate);
//Update Text of Title
document_test.Replace("#trainee_name#", trainee.Name, false, true);
document_test.Replace("#course_name#", "Test", false, true);
document_test.Replace("#date_info#", DateTime.Today.ToShortDateString(), false, true);
document_test.SaveToFile(nnn, Spire.Doc.FileFormat.PDF, System.Web.HttpContext.Current.Response, HttpContentType.Attachment);
}
The Code works perfectly on the local development machine, but when i upload it to Azure web app i get a this generic error: A generic error occurred in GDI+.
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, String description) +226801
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) +34
sprᲦ.ᜀ(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3, GraphicsUnit A_4) +255
sprᲦ.ᜀ(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3) +19
sprᲦ.᜔() +224
sprᲦ.ᜁ(IDocument A_0) +234
spr᧤.ᜀ(Document A_0) +93
Spire.Doc.Document.ᜀ(Stream A_0) +94
Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat) +289
Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat, HttpResponse response, HttpContentType contentType) +673
LMSv1.Controllers.DisplayController.DownloadCertification(Nullable1 tid, Nullable
1 eid) +616
lambda_method(Closure , ControllerBase , Object[] ) +146
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +167
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End() +49