Error when using Pdf Viewer

Hi,

I use your pdf Viewer (version 18.3.0.48) in my application. When showing a page i got the error:

Unexpected token T in JSON at position 0
SyntaxError: Unexpected token T in JSON at position 0
    at JSON.parse (<anonymous>)
    at t.pdfViewer.serverActionSettings.loadRequestHandler.onSuccess (https://localhost:44348/_content/Syncfusion.Blazor/scripts/pdfviewer-02f9b7.min.js:1:1119398)
    at t.successHandler (https://localhost:44348/_content/Syncfusion.Blazor/scripts/pdfviewer-02f9b7.min.js:1:1306851)
    at Object.ioSuccessHandler (https://localhost:44348/_content/Syncfusion.Blazor/scripts/syncfusion-blazor.min.js:1:173812)
    at https://localhost:44348/_framework/blazor.server.js:1:70043
    at new Promise (<anonymous>)
    at e.beginInvokeJSFromDotNet (https://localhost:44348/_framework/blazor.server.js:1:70009)
    at https://localhost:44348/_framework/blazor.server.js:1:26293
    at Array.forEach (<anonymous>)
    at e.invokeClientMethod (https://localhost:44348/_framework/blazor.server.js:1:26263)

13 Replies 1 reply marked as answer

AA Akshaya Arivoli Syncfusion Team November 12, 2020 08:56 AM UTC

Hi Aitlahmid, 

Thank you for contacting Syncfusion support. 

We were unable to reproduce the reported error with the provided details. We have shared the sample in which we have tried to reproduce in the below link, 


Kindly try it and revert us with more details about your issue and the modified sample if you still need further assistance. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya 



AI aitlahmid November 12, 2020 03:56 PM UTC

Hi,

Thank you for your response. 

Resolved.


MS Mohan Selvaraj Syncfusion Team November 13, 2020 07:38 AM UTC

Hi Aitlahmid,  

Thanks for your update. 

We are glad to know that the reported issue is resolved in your end. Kindly revert if there is any concern. 

Regards, 
Mohan S 



AI aitlahmid November 13, 2020 02:19 PM UTC

Hi,

After deploying the application Sample above, in Linux (Debian 9), the same error appeared.

Thank you.


AA Akshaya Arivoli Syncfusion Team November 16, 2020 12:38 PM UTC

Hi Aitlahmid, 


Thank you for your update. 

Based on the provided details we suspect that the write access permission is denied so the exception is thrown. We have embedded the Pdfium rendering engine in our PDF Viewer for robust rendering, so Pdfium dll (libpdfium.so)  will be generated on runtime within your project location. So kindly provide read and write access to your project location. 
       
    
Note:    
    
Kindly use Syncfusion.Blazor.PdfViewerServer.Linux  package in your application for Linux environment. Also, ensure whether the library dependencies of libpdfium.so are installed properly. Also, avoid installing both Windows and Linux packages in the same project. If not, 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        
    
  
  


Kindly try it and revert us with more details if you have any concerns. This will be helpful for us to investigate further and assist you better. 


Regards,  
Akshaya   




AI aitlahmid November 24, 2020 10:01 AM UTC

Hi,

Thank you for your response.

After executing the commands, always the same error.

Help please.

Thanks.


AA Akshaya Arivoli Syncfusion Team November 26, 2020 03:50 AM UTC

Hi Aitlahmid, 

Thank you for your update. Can you please provide more details about your issue, environment details, and confirm whether the Pdfium dll (libpdfium. so) was generated on runtime within your project location. If not as mentioned earlier, kindly provide the write access to your project.  If you are still facing the issue, we can set up 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  



AI aitlahmid November 28, 2020 02:40 PM UTC

Hi,

I, have two questions

1- I don't unserestand the sentences in Bold:
Kindly use Syncfusion.Blazor.PdfViewerServer.Linux  package in your application for Linux environment. Also, ensure whether the library dependencies of libpdfium.so are installed properly. Also, avoid installing both Windows and Linux packages in the same project. If not, please execute the following command to install the dependencies.

2- To deploy a blazor application on Linux, I should create and build it on the Linux environment?

3- Can you tell me the steps to successfully deploy a blazor application (pdf viewer) in the Linux environment: on which environment to develop it, how to publish it, The prerequisites on the Linux deployment server ...

Thanks.


AA Akshaya Arivoli Syncfusion Team November 30, 2020 12:55 PM UTC

Hi Aitlahmid, 

Thank you for your update. 

Please find the details of your query below, 

Query 
Details 
              - I don't understand the sentences in Bold: 
Kindly use Syncfusion.Blazor.PdfViewerServer.Linux package in your application for the Linux environment. Also, ensure whether the library dependencies of libpdfium. so are installed properly. Also, avoid installing both Windows and Linux packages in the same project. If not, please execute the following command to install the dependencies. 
 
We need to install Syncfusion.Blazor.PdfViewerServer.Linux package in your project and then build the project in a Linux environment and deploy the same in Linux. 
 
 
 
 
 
To deploy a blazor application on Linux, I should create and build it on the Linux environment? 
Can you tell me the steps to successfully deploy a blazor application (pdf viewer) in the Linux environment: on which environment to develop it, how to publish it, The prerequisites on the Linux deployment server ... 
As we mentioned earlier, we need to install only Syncfusion.Blazor.PdfViewerServer.Linux package in your project. Build the project in your Linux environment and then deploy the same in Linux environment.   
 
Also, ensure to provide write access permission to your project, so that the libpdfium.so file will be generated while running the project.  
 
Kindly try it and revert us with more details if you still have concerns. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya 


Marked as answer

AI aitlahmid December 8, 2020 11:26 AM UTC

Hi,

The problem is resolved after building the solution in Linux Platform.

Thanks for your excelent support.




AA Akshaya Arivoli Syncfusion Team December 9, 2020 08:27 AM UTC

Hi Aitlahmid, 

We were glad to know that the reported issue was resolved. Please revert if you need any assistance in the future. 

Regards, 
Akshaya 



JI Jirí May 11, 2021 03:37 PM UTC

Hello,

I have some issue with server side Blazor and PDF Viewer in linux. I spend a lot of hours with testing, but without luck.

1)  Syncfusion.Blazor.PdfViewerServer.Linux package included.
2) The project was compiled on Windows (with target linux), also I tried build it on Linux directly - no luck.
3)  Full access rights on whole project folder.

.NET 5
OS version:
 Operating System: CentOS Linux 8 (Core)
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-147.8.1.el8_1.x86_64
      Architecture: x86-64

How can I debug this component and find what is wrong? The error messages in browser console are unusable. Thank you.




DM Dhivyabharathi Mohan Syncfusion Team May 12, 2021 08:30 AM UTC

Hi Giri, 
 
Thank you for contacting Syncfusion support.  
 
We suspect that the reported issue occurs due to the missing of the Pdfium.dll in your environment. We have embedded the Pdfium rendering engine in our PDF Viewer, so the Pdfium.dll will be generated on runtime within your project location.     
     
However, we have exposed the ReferencePath API to set the pdfium library location path. We can place the pdfium library in project location and refer the project location to the ReferencePath. 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:  
  
Kindly use the  Syncfusion.EJ2.PdfViewer.AspNet.Core.Linux  package in your application for linux environment . 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 \      
        libc6-dev \      
        libgdiplus \      
        libx11-dev \      
        curl \      
        vim \      
        supervisor \      
        procps      
  
 
Please try this and revert us with more details if you are still facing the issue. It will be helpful for us to investigate further and assist you better.  
 
 
Regards, 
Dhivya. 


Loader.
Up arrow icon