You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The print pdf button works fine for the first time but when again I am clicking Print pdf button the app is crashing. I have test this in UWP simulator.
Exception Details
System.InvalidOperationException
HResult=0x80131509
Message=Must not change font resolver after is was once used.
Source=PdfSharpCore
StackTrace:
at PdfSharpCore.Fonts.GlobalFontSettings.set_FontResolver(IFontResolver value)
at PDFDemo.PDFReports.ProductsReport..ctor(List`1 items) in D:\Demos\PDFDemo-master\PDFDemo-master\PDFDemo\PDFDemo\PDFReports\ProductsReport.cs:line 30
at PDFDemo.ViewModels.ProductListViewModel.<PrintPdf>d__17.MoveNext() in D:\Demos\PDFDemo-master\PDFDemo-master\PDFDemo\PDFDemo\ViewModels\ProductListViewModel.cs:line 46
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at PDFDemo.ViewModels.ProductListViewModel.<<-ctor>b__19_1>d.MoveNext() in D:\Demos\PDFDemo-master\PDFDemo-master\PDFDemo\PDFDemo\ViewModels\ProductListViewModel.cs:line 64
This exception was originally thrown at this call stack:
[External Code]
PDFDemo.PDFReports.ProductsReport.ProductsReport(System.Collections.Generic.List<PDFDemo.Models.Product>) in ProductsReport.cs
PDFDemo.ViewModels.ProductListViewModel.PrintPdf() in ProductListViewModel.cs
[External Code]
PDFDemo.ViewModels.ProductListViewModel..ctor.AnonymousMethod__19_1() in ProductListViewModel.cs
The text was updated successfully, but these errors were encountered:
In this proyect he generates the pdfs using a command in "ProductListViewModel". The first time the user generates the pdf the fonts are loaded. The following times the user generates a pdf the fonts aren´t loaded so it doesn´t fail
private async Task PrintPdf()
{
//this is the try-catch you have to add in ProductListViewModel
try
{
GlobalFontSettings.FontResolver = new GenericFontResolver();
var pdfReport = new PDFReports.ProductsReport(products);
await pdfReport.CreateReport();
}
catch
{
var pdfReport = new PDFReports.ProductsReport(products);
await pdfReport.CreateReport();
}
}
The print pdf button works fine for the first time but when again I am clicking Print pdf button the app is crashing. I have test this in UWP simulator.
Exception Details
The text was updated successfully, but these errors were encountered: