We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

PdfViewer 'kernel32' Error

Thread ID:

Created:

Updated:

Platform:

Replies:

147020 Aug 29,2019 01:45 AM UTC Sep 6,2019 04:58 AM UTC ASP.NET Core - EJ 2 8
loading
Tags: PDF Viewer
Maral
Asked On August 29, 2019 01:45 AM UTC

Hi I'm using Syncfusion.EJ2.PdfViewer and while running the following line in my code
var jsonResult = pdfRenderer.Load(documentPath, jsonObject);
I get the following exception:
{System.DllNotFoundException: Unable to load shared library 'kernel32' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libkernel32, 1): image not found
at Syncfusion.EJ2.PdfViewer.PdfiumNative.LoadLibrary(String lpFileName)
at Syncfusion.EJ2.PdfViewer.PdfiumNative.ExtractPdfiumLibrary()
at Syncfusion.EJ2.PdfViewer.PdfiumNative..cctor()}
I am running on macOS Mojave version 10.14.6 using Visual Studio IDE community 8.2.4 (build 17) version.
I've been stuck on this and I would very much appreciate any help.
Kind Regards,
Maral

Akshaya Arivoli [Syncfusion]
Replied On August 29, 2019 08:39 AM UTC

Hi Maral , 

Thank you for contacting Syncfusion support. 

Based on the provided details we suspect that you have referred the Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows NuGet package in your project instead of Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX. Kindly refer the Syncfusion.EJ2.PdfViewer.AspNetCore.OSX in your project to work in Mac OS. We have created simple PDF Viewer sample and shared the same in the following location, 


Please find the UG link from the below, 


Please try with this and revert us with more details about your issue if you are still facing the issue. 

Regards, 
Akshaya 


Maral
Replied On August 29, 2019 02:10 PM UTC

Hi,

Thank you so much for your prompt reply. 
I now added the Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX  package and removed the Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows package from the dependency folder. I think I still need to make some changes. I appreciate your kind help. I have attached my previous error and current error as the "before" and "after" files.

Attachment: Errors_1bbf46bb.zip

Akshaya Arivoli [Syncfusion]
Replied On August 30, 2019 12:02 PM UTC

Hi Maral, 

We are unable to reproduce the reported issue with the provided sample. Based on the provided details we suspect that you have not updated the controller code as provided in the sample. From the version 17.2.0.39, we have improved the memory cache method in ASP.NET Core. So, update the controller code as provided in the previous sample to work with PDF Viewer. 

Code Snippet
private readonly IHostingEnvironment _hostingEnvironment; 
        private IMemoryCache _cache; 
        public PdfViewerController(IHostingEnvironment hostingEnvironment, IMemoryCache cache) 
        { 
            _hostingEnvironment = hostingEnvironment; 
            _cache = cache; 
        } 
  [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/Load")] 
        public IActionResult Upload([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            MemoryStream stream = new MemoryStream(); 
           object jsonResult = new object(); 
           if (jsonObject != null && jsonObject.ContainsKey("document")) 
            { 
                if (bool.Parse(jsonObject["isFileName"])) 
                {                     
                   string documentPath = GetDocumentPath(jsonObject["document"]); 
 
                    if (!string.IsNullOrEmpty(documentPath)) 
                    { 
                        byte[] bytes = System.IO.File.ReadAllBytes(documentPath); 
                        //_stream = new FileStream(documentPath, FileMode.OpenOrCreate); 
                        stream = new MemoryStream(bytes);             
                         
                    } 
                    else 
                    {        
                        return this.Content(jsonObject["document"] + " is not found"); 
                    } 
                } 
                else 
                { 
                    byte[] bytes = Convert.FromBase64String(jsonObject["document"]);                     
                    stream = new MemoryStream(bytes); 
                } 
            }            
            jsonResult = pdfviewer.Load(stream, jsonObject); 
           return Content(JsonConvert.SerializeObject(jsonResult));            
        }    
 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/RenderPdfPages")] 
        public IActionResult RenderPdfPages([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache);          
 
            object jsonResult = pdfviewer.GetPage(jsonObject); 
 
            return Content(JsonConvert.SerializeObject(jsonResult)); 
        } 
 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/RenderAnnotationComments")] 
        public IActionResult RenderAnnotationComments([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            object jsonResult = pdfviewer.GetAnnotationComments(jsonObject); 
            return Content(JsonConvert.SerializeObject(jsonResult)); 
        } 
 
 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/Unload")] 
        public IActionResult Unload([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            pdfviewer.ClearCache(jsonObject); 
            return this.Content("Document cache is cleared"); 
        } 
 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/RenderThumbnailImages")] 
        public IActionResult RenderThumbnailImages([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            object result = pdfviewer.GetThumbnailImages(jsonObject); 
            return Content(JsonConvert.SerializeObject(result)); 
        } 
 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/Bookmarks")] 
        public IActionResult Bookmarks([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            object jsonResult = pdfviewer.GetBookmarks(jsonObject); 
            return Content(JsonConvert.SerializeObject(jsonResult)); 
        } 
 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/Download")] 
        public IActionResult Download([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject); 
            return Content(documentBase); 
        }        
 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("api/[controller]/PrintImages")] 
        public IActionResult PrintImages([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(_cache); 
            object pageImage = pdfviewer.GetPrintImage(jsonObject); 
            return Content(JsonConvert.SerializeObject(pageImage)); 
        }         

Please find the below KB for reference, 

Please try this and let us know if you have any concerns on this. 

Regards, 
Akshaya 



Maral
Replied On August 30, 2019 12:40 PM UTC

Hi,

Thank you so much for your reply. I do not have a controller code as I am using razor pages. I apologize for not providing that information earlier. I created a new thread ( Thread ID: 147053) yesterday to report this issue with more details and a more relevant subject. Please refer to https://www.syncfusion.com/forums/147053/pdf-is-not-loading-on-mac
Please let me know if you need more information. I appreciate the help very much.

Thanks,
Maral

Maral
Replied On August 30, 2019 10:36 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

Akshaya Arivoli [Syncfusion]
Replied On September 3, 2019 01:23 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 


Maral
Replied On September 5, 2019 07:09 PM UTC

Hi Akshaya,

This was super helpful. I was able to upgrade my Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX package and made the required the changes regarding the new cache method to my code. 

Thank you for your help.

Kind Regards,
Maral

Akshaya Arivoli [Syncfusion]
Replied On September 6, 2019 04:58 AM UTC

Hi Maral, 

We are glad to hear that your issue is resolved.  

Regards, 
Akshaya 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon