The issue, “The type initializer for ‘Syncfusion.EJ2.PdfViewer.PdfiumNative’ threw an exception” is due to the write access permission denied in the environment. The pdfium.dll will be created based on the operating system at the runtime. Due to the denial of permission, the pdfium.dll file couldn’t have been created. So, copy the below x64 and x86 folders and paste them inside the folder into your project to resolve the issue or enable the write permission for that folder.
Pdfium dll: pdfium.dll
Note: · Kindly use both the client and server-side of the same version in your project. · Ensure whether the pdfium.dll file is created in your project during runtime. Else, place the pdfium assemblies in any of the production environment locations and refer to the path by using the ReferencePath API.
For example, if the Pdfium assembly is available in this path C:\Pdfium\x64 or D:\Pdfium\x86, the reference path should be PdfRenderer.ReferencePath = “C:/“;
The parent folder has to be provided as the path in the ReferencePath API.
Note: Provide this path in the Load method of the PDFViewerController.cs
PdfRenderer PdfRenderer = new PdfRenderer(); PdfRenderer.ReferencePath = @“C:/“;
Also, install only the package related to that OS, then build and run the project on that platform. For Windows, Linux, and OSX operating systems, use the following corresponding libraries:
• Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux • Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows • Syncfusion.EJ2.PdfViewer.AspNet.Core.OSX
Following these steps should resolve the issue.