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. Image for the cookie policy date

PdfViewer 'kernel32' Error

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

8 Replies

AA Akshaya Arivoli Syncfusion Team 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 



MA Maral 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


AA Akshaya Arivoli Syncfusion Team 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 




MA Maral 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


MA Maral 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


AA Akshaya Arivoli Syncfusion Team 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 



MA Maral 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


AA Akshaya Arivoli Syncfusion Team September 6, 2019 04:58 AM UTC

Hi Maral, 

We are glad to hear that your issue is resolved.  

Regards, 
Akshaya 


Loader.
Live Chat Icon For mobile
Up arrow icon