The type initializer for 'Gdip' threw an exception in renderpdfpages api

I am using .netcore application and using pdfviewer. 

I launched my application in linux.

I added the nuget package ej2.pdfviewer.aspnet.core.linux.

In renderpdfpages api - i am getting an error 

The type initializer for 'Gdip' threw an exception

can you help me find out whats the issue

public IActionResult RenderPdfPages([FromBody]Dictionary<string, string> jsonObject)
    {
        PdfRenderer pdfviewer = new PdfRenderer(_cache);
        object jsonResult = pdfviewer.GetPage(jsonObject);
        return Content(JsonConvert.SerializeObject(jsonResult));
    }

1 Reply 1 reply marked as answer

VS Vasugi Sivajothi Syncfusion Team October 21, 2021 10:43 AM UTC

Hi Swethaa, 
  
Thank you for contacting Syncfusion support. 
  
We suspect that the reported issue is due to the write access permission is denied in the environment, so the reported issue may have occurred. We have embedded the Pdfium rendering engine in our PDF Viewer for robust rendering, we will create the pdfium.dll based on the operating system during the runtime of the control.  So pdfium.dll (libpdfium.so) will be generated on runtime within your project location. Kindly provide read and write access to your project location.   
  
And please ensure whether the library dependencies of libpdfium.so are installed properly. Also, avoid installing both Windows and Linux packages in the same project. And please execute the following command to install the dependencies.  
   
   
RUN apt-get update \          
    && apt-get install -y --allow-unauthenticated \          
        libc6-dev \          
        libgdiplus \          
        libx11-dev \          
        curl \          
        vim \          
        supervisor \          
        procps          
   
  
  
sudo apt install libc6-dev
sudo apt install libgdiplus
 
  
  
  
Kindly try this and let us know if the issue resolves or not. If not, please share more details about the package version details and error details. This will be helpful to investigate further and provide the solution at the earliest. 
  
Regards, 
Vasugi. 


Marked as answer
Loader.
Up arrow icon