Pdf Viewer rendering on Linux (EC2) rendering issue

Hi,

I'm using Syncfusion ASP.NET Core for my PoC.
One of the problems that i have is that Pdf Viewer is not rendering 

So, Linux library is included before publishing (Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux) to EC2 Linux instance.

I'm getting something like this. I did a debug logging, and actual controller is being hit and proper stream is being produced in Load controller endpoint.


Everything works well when deployed on Windows.

Can someone help me out with this?

Regards,
Danilo


15 Replies

AA Akshaya Arivoli Syncfusion Team March 9, 2020 11:42 AM UTC

Hi Danilo, 

Thank you for contacting Syncfusion support. 

Based on the provided details we suspect that the write access permission is denied so the exception will be thrown in server side which caused the reported issue. We have embedded the Pdfium rendering engine in our PDF Viewer for robust rendering, so libpdfium.so will be generated on runtime within your project location. So can you please provide write access to your project location. Else we can place the pdfium library in project location and refer the project location to the ReferencePath API. Please find the below code to set the pdfium location inside the wwwroot folder.   
  
Code snippet:     
 
PdfRenderer.ReferencePath = _hostingEnvironment.WebRootPath + "\\";   
    
Example:    
     
public IActionResult Load([FromBody] Dictionary<stringstring> jsonObject)   
        {   
           PdfRenderer pdfviewer = new PdfRenderer(_cache);   
          PdfRenderer.ReferencePath = _hostingEnvironment.WebRootPath + "\\";   
            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 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));   
        }   
     
We have also shared the Pdfium dll in the below link,   
  
 
Note:  While working in Linux environment please install only the Linux packages(Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux) in your project and then build and deploy it in Linux environment. Kindly avoid installing both Windows and Linux packages in the same project.    

Also, ensure whether the library dependencies of libpdfium.so are installed properly. If not, please execute the following command to install the dependencies   

RUN apt-get update \     
    && apt-get install -y --allow-unauthenticated \     
export LD_LIBRARY_PATH=/lib64/    
        libc6-dev \     
        libgdiplus \     
        libx11-dev \     
        curl \     
        vim \     
        supervisor \     
        procps     
 


Please try it and revert us with more details about your issue, exception/console error details if any. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya 



DA Danilo A March 9, 2020 04:35 PM UTC

Hi,

I'm using Amazon Linux 2.



So apt-get is not available for me. Yum is.

All in all, I'm facing the same problem.

You can see that libpdfium.so is generated in wwwroot and see the rights.



I've added reference path like so (since I'm running .Net core 3.1.):

PdfRenderer.ReferencePath = _hostingEnvironment.ContentRootPath + string.Format(@"{0}wwwroot", Path.DirectorySeparatorChar);

I'm getting this response now. Any hints?

"The type initializer for 'Syncfusion.EJ2.PdfViewer.PdfiumNative' threw an exception."


DA Danilo A March 10, 2020 12:54 PM UTC

Hi again,

Any feedback regarding this matter?

Please provide some further actions regarding Linux environment where application is deployed.

# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

Regards



AA Akshaya Arivoli Syncfusion Team March 10, 2020 01:13 PM UTC

Hi Danilo, 

Thank you for your update. 

Can you please run the below commands in the system root folder instead of the project location to install the dependencies of libpdfium.so 

export LD_LIBRARY_PATH=/lib64/  
sudo apt-get update       
sudo apt-get install -y --allow-unauthenticated   
sudo apt install yum libc6-dev   
sudo apt install yum  libgdiplus   
sudo apt install yum libx11-dev   
sudo apt install yum curl   
sudo apt install yum vim   
sudo apt install yum supervisor   
sudo apt install yum  procps      



Please try it and revert us with more details if you still have concerns. It will be helpful for us to investigate further and assist you bette. 

Regards, 
Akshaya 



DA Danilo A March 10, 2020 02:24 PM UTC

Hi,

Have you tried to run these commands provided environment?
apt and apt-get are not available.

However, when I try to run following dependecies, i get :
# sudo yum install libc6-dev
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                            | 2.4 kB  00:00:00
2 packages excluded due to repository priority protections
No package libc6-dev available.
Error: Nothing to do


// Regards


DA Danilo A March 10, 2020 03:47 PM UTC

I've did some installation of pdfium prereq's, and now I'm getting Segmentation fault:

[15:13:50 DBG] PDF Load. Producing report!
[15:13:53 DBG] PDF Load. Report produced! Lenght: 17344
[15:13:53 DBG] PdfRenderer.ReferencePath : /usr/lib/
^C
[1]+  Segmentation fault

It seems like a issue with pdfium.
Any hints?

Regads


AA Akshaya Arivoli Syncfusion Team March 11, 2020 12:52 PM UTC

Hi Danilo, 

We are currently working on creating the environment to check for the reported issue. We will update you with further details on March 13th, 2020 

Regards, 
Akshaya 



DA Danilo A March 11, 2020 02:29 PM UTC

Hi,

Just tried everything on Ubuntu (since in your initial script apt-get was used), and it's the same thing there.
All prereq's are installed.
Ubuntu 18.04. used.

# cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic





Please let me know how to fix this...

Regards


AA Akshaya Arivoli Syncfusion Team March 12, 2020 04:40 PM UTC

Hi Danilo , 

We have installed the ‘libpdfium.so’ dependencies as we mentioned earlier and we are unable to reproduce the reported issue with Ubuntu 18.04 version. So please install the dependencies and if you still have concerns, we can setup a web meeting to look into the reported issue in your environment and provide the solution. Please let us know your availability. We will make every effort to have this scheduled on a date and time of your convenience.       

Regards, 
Akshaya 




DA Danilo A March 12, 2020 07:13 PM UTC

Hi Akshaya,

Thanks for update!

This environment is something where i will do a deployment (not Ubuntu).

# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

But, we can have a Google hangouts session. I guess that you have my e-mail.

In the meantime, can you provide me solution that you tried?
I.e. VS solution and also shell script with prereqs that was executed on Ubuntu or Docker image? 


Regards,
Danilo




AA Akshaya Arivoli Syncfusion Team March 13, 2020 02:11 PM UTC

Hi Danilo  

A support incident to track the status of reported issue has been created under your account. Please log on to our support website to check for further updates.      


Please let us know if you have any concern on this. 

Regards, 
Akshaya 



SV Sandhya Verma replied to Akshaya Arivoli February 3, 2023 12:05 PM UTC

I am also facing same issue with linux i am unable to render pdf viewer



CK Chinnamunia Karthik Chinna Thambi Syncfusion Team February 6, 2023 12:36 PM UTC

Find the documentation link on how to resolve the Pdfium issue.


https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/how-to/resolve-pdfium-issue


Kindly try this and let us know if this helps.


If you have any concerns in this, you can share the error details, code snippets, and sample in which the issue is reproduced, and also share the network tab response as in the screenshot in a private ticket. We will check and get this resolved soon.




CB Chris Burger September 19, 2023 09:48 AM UTC

Did any of the steps worked for anyone? I have aws Ubuntu ec2 instance and facing this issue. How come it is not resolved yet. I tried all the steps suggested here and still getting the very same issue.



CK Chinnamunia Karthik Chinna Thambi Syncfusion Team September 25, 2023 04:50 AM UTC

Could you confirm whether the pdfium dependency is installed in your environment. If it's not installed, please follow the below commands one by one to install the pdfium dependency on your environment and test the scenario once.

 

 

    sudo apt-get install libfontconfig1

    sudo apt-get update && apt-get install -y --allow-unauthenticated libgdiplus libc6-dev libx11-dev

    sudo apt-get update

    sudo apt install libgdiplus

 

If you have any concerns, we kindly request that you check and provide the network tab information, as shown in the screenshot below. Additionally, please share the details of the NuGet packages you are using.

 


Loader.
Up arrow icon