- Home
- Forum
- ASP.NET Core - EJ 2
- PDF is not loading on mac
PDF is not loading on mac
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
SIGN IN To post a reply.
2 Replies
MA
Maral
August 30, 2019 10:37 PM UTC
*Update:
After you mentioned the changes applied to version 17.2.0.39, I downgraded my asp.net core package to 17.2.0.34 and now it is working! Thank you so much for your help. I really do appreciate it.
Kind Regards,
Maral
AA
Akshaya Arivoli
Syncfusion Team
September 3, 2019 01:27 PM UTC
Hi Maral,
Thank you for your update.
We can use the PDF Viewer in Razor pages and find the below KB link for the same with updated the code snippet and the sample,
Please try this and let us know if you have any concerns on this.
Regards,
Akshaya
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
MA Maral
- Aug 30, 2019 07:27 AM UTC
- Sep 3, 2019 01:27 PM UTC