I have a class that is being used as a strategy to convert HTML to PDF.
public byte[] Execute(byte[] document, Dictionary<string, string> parameters)
{
try
{
var localReporting = new LocalReporting();
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
localReporting.UseBinary(jsreport.Binary.OSX.JsReportBinary.GetBinary());
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
localReporting.UseBinary(jsreport.Binary.OSX.JsReportBinary.GetBinary());
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
localReporting.UseBinary(jsreport.Binary.JsReportBinary.GetBinary());
}
ILocalUtilityReportingService reportingService = localReporting.AsUtility().Create();
var report = reportingService.RenderAsync(new RenderRequest()
{
Template = new Template()
{
Recipe = Recipe.PhantomPdf,
Engine = Engine.None,
Content = Encoding.UTF8.GetString(document)
}
});
report.Wait();
return report.Result.Content.ToByteArray();
}
catch(Exception ex)
{
return null;
}
}
When I call this Execute method, either from my controller action or via a console app I get the error message exception :
{jsreport.Local.JsReportBinaryException: Error rendering report: at jsreport.Local.Internal.LocalUtilityReportingService.<RenderAsync>d__10.MoveNext()}
I have added the NuGet packages; jsreport.aspnetcore, jsreport.Binary.Linux (& OSX, Windows), jsreport.Local. The intention is pass any HTML to the strategy and get a PDF returned.
Appreciate any help and questions.