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
close icon

PDF Viewer Unable to load shared library 'libpdfium.so'

Hi, I'm using EJ2 .Net Core PDFViewer to load a PDF file and then convert it to an image. For Windows version, the library that I load are:
  • Syncfusion.EJ2.AspNet.Core
  • Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows
just like the documentation here. And it worked just fine, however when I tried to run it on my Linux machine (to be exact in my Raspbian OS release date 2019-09-26) I found some issue.

So for the Linux, I replaced the Syncfusion.EJ2.PdfViewer.AspNet.Core.Windows and use Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux instead (just like in this thread where we need to remove the Windows with the platform that we are targeted). When I run my web application, I got this error message:
"Unable to load shared library 'libpdfium.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibpdfium.so.so: cannot open shared object file: No such file or directory". But when I looked at my folder, the libpdfium.so is there

Is there something that I missed to get PDFViewer working on Linux?

8 Replies

AA Akshaya Arivoli Syncfusion Team December 16, 2019 11:48 AM UTC

Hi Anova, 
  
Thank you for contacting Syncfusion support. 
  
Based on the provide details we suspect the you are trying to run the project in Linux environment with the packages and Pdfium dll build on Windows environment. So, can you please delete the bin, obj and Pdfium dll, then rebuild the project before running in Linux environment. We have shared the sample with Linux package (ExportAsImage_Linux.sln) in the below link, 
  
  
Also ensure whether the dependencies for the libpdfium.so are installed, if not can you please install it by adding the following code,   
    
RUN apt-get update \    
    && apt-get install -y --allow-unauthenticated \    
        libc6-dev \    
        libgdiplus \    
        libx11-dev    
  
  
Please try with the provided sample and revert us with the error details, modified sample with replication procedure and Essential Studio Version if you are still facing the issue. These details will be helpful for us to investigate further on your issue and assist you better.  
  
Regards, 
Akshaya 



AN Anova December 17, 2019 02:30 PM UTC

Hi Akshaya,

After I double check my Raspbian /usr/lib, apparently there are no libpdfium.so exists. How can I install the PDFium in my Linux easily? Should I do the build manually? To make it clear and easy to replicate, I have attached a simple .net core application (I forgot to tell you that my application was based on .net core 2.2.402). This application only load a pdf and directly convert it to png just like your example, the error message still the same.

I have install the libpdfium dependencies as you said and this project is created entirely on Linux machine, so I'm pretty sure it doesn't mixed up with the Windows build files.

Could you have a look at my attachment and let me know what I'm missing?

Cheers,
Anova

Attachment: linuxpdf_fd5e2517.zip


AA Akshaya Arivoli Syncfusion Team December 20, 2019 12:56 PM UTC

Hi Anova, 

Thank you for your update. 

We are unable to reproduce the reported issue with the provided sample in Linux environment. Pdfium dll(libpdfium.so) will be generated in runtime on loading the Pdf Document. We suspect that permission is denied to your project location, so the Pdfium dll are not generated. However we can set the Pdfium location manually using the ReferencePath API available in PDF Viewer. Please find the code snippet for the same from the below, 

static void Main(string[] args) 
        { 
            Console.WriteLine("Start to convert pdf to image"); 
            PdfRenderer pdf = new PdfRenderer(); 
              // Provide your path here and place the lippdfium in that location 
              PdfRenderer.ReferencePath = "/home/syncfusion"; 
            pdf.Load("input.pdf"); 
            // get current size 
            Bitmap org = pdf.ExportAsImage(0); 
            Size orgSize = org.Size; 
            // double up the size 
            Bitmap bitmapToPng = pdf.ExportAsImage(0, new SizeF(orgSize.Width * 2, orgSize.Height * 2), true); 
            bitmapToPng.Save("output.png"); 
        } 

We have also shared the lippdfium.so file in the below location, please place this dll in the path provided in ReferencePath API  


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

Regards, 
Akshaya 



AN Anova January 6, 2020 02:57 AM UTC

Hi Akshaya,

Thank you very much for your help, sorry for the late reply after the end of year holiday. I have updated the PdfViewer.AspNet.Core.Linux and also other library to the latest version (17.4.0.40) to have the ReferencePath API and placed your libpdfium.so file inside that accessible folder, unfortunately the .net core still couldn't load the shared library (still with the same error message). 

Do you know where does the default folder that I should placed the .so file? I have tried to put it under /usr/lib, also under the created /bin and /obj folder. I'm also have tried to add LD_LIBRARY_PATH just like this but still no luck. 


AN Anova January 6, 2020 04:36 AM UTC

Just to make sure the library was loaded, I check it using 'ldconfig -v' and the result are attached.

Thank you for your help.

Attachment: ldconfig_a7e5af7.zip


AA Akshaya Arivoli Syncfusion Team January 7, 2020 12:38 PM UTC

Hi Anova, 

Based on the provided details Pdfium dll  is not mapped properly, can you please try with the below code as you have  
placed the Pdfium dll in /usr/lib folder 

static void Main(string[] args)  
        {  
            Console.WriteLine("Start to convert pdf to image");  
            PdfRenderer pdf = new PdfRenderer();  
              // Provide your path here and place the lippdfium in that location  
              PdfRenderer.ReferencePath = “/usr/lib/ ";  
            pdf.Load("input.pdf");  
            // get current size  
            Bitmap org = pdf.ExportAsImage(0);  
            Size orgSize = org.Size;  
            // double up the size  
            Bitmap bitmapToPng = pdf.ExportAsImage(0, new SizeF(orgSize.Width * 2, orgSize.Height * 2), true);  
            bitmapToPng.Save("output.png");  
        }  


Please try with this and revert us with more details and the modified sample if you are still facing the issue. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya 



AN Anova January 7, 2020 11:17 PM UTC

Thanks Akshaya,

Unfortunately I'm still facing the issue, could you try with my modified example? I have attached the screenshot of the error as well.

Attachment: linuxpdf_d7b5dc0b.zip


MS Mohan Selvaraj Syncfusion Team January 10, 2020 02:30 PM UTC

Hi Anova, 

Thank you for your update. 

We suspect that permission issue in accessing the Pdfium dll from the /usr/lib. So can Please try placing the Pdfium dll in the Documents folder and mention the same path in the ReferencePath. We have shared the sample in the below link, 


Console.WriteLine("Start to convert pdf to image"); 
            PdfRenderer pdf = new PdfRenderer(); 
       // instead of Syncfusion please provide your user name. 
            PdfRenderer.ReferencePath = "/home/syncfusion/Documents"; 
            pdf.Load("input.pdf"); 
            // get current size 
            Bitmap org = pdf.ExportAsImage(0); 
            Size orgSize = org.Size; 
            // double up the size 
            Bitmap bitmapToPng = pdf.ExportAsImage(0, new SizeF(orgSize.Width * 2, orgSize.Height * 2), true); 
            bitmapToPng.Save("output.png"); 


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


Regards, 
Mohan S 


Loader.
Live Chat Icon For mobile
Up arrow icon