Hi,
I'm running a project based on razor pages that uses pdfviewer page and page model. I am running on the mac environment and I use VS community 8.2.5.
I am using the following OnPOSTLoad() for my
public IActionResult OnPostLoad([FromBody] Dictionary<string, string> jsonObject)
{
if (jsonObject == null)
{
return this.Content($"{nameof(jsonObject)} is null");
}
try
{
if (jsonObject.TryGetValue("document", out var fileName))
{
var documentPath = GetDocumentPath(fileName);
if (!string.IsNullOrEmpty(documentPath))
{
var pdfRenderer = new PdfRenderer();
var jsonResult = pdfRenderer.Load(documentPath, jsonObject);
return Content(JsonConvert.SerializeObject(jsonResult));
}
else
{
return this.Content(jsonObject["document"] + " is not found");
}
}
else
{
return this.Content($"document is missing in {nameof(jsonObject)}");
}
}
catch (Exception ex)
{
return this.Content($"Exception: {ex}");
}
an exception occurs on line
var jsonResult = pdfRenderer.Load(documentPath, jsonObject);
following is the exception info:
Message : Object reference not set to an instance of an object.
Source : Microsoft.Extensions.Caching.Abstractions
StackTrace: at Microsoft.Extensions.Caching.Memory.CacheExtensions.TryGetValue[TItem](IMemoryCache cache, Object key, TItem& value)\n at Syncfusion.EJ2.PdfViewer.PdfRenderer.Load(String filePath, Dictionary`2 jsonObject)\n at AHC.BaseTemplate.Areas.CommandCenter.Pages.CareGapManager.GuidelinesModel.OnPostLoad(Dictionary`2 jsonObject) in /Users/mamir/mygit/CC-vNext/AHC.WebApps/Areas/CommandCenter/Pages/CareGapManager/Guidelines.cshtml.cs:line 122
So I have not been able to load the pdf document. I have to mention that this problem does apply when running the code in the windows env and the pdf document loads in windows.
I very much appreciate any help.
Thanks,
Maral