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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Strange Issue with PDF Viewer when deployed to web server

Thread ID:

Created:

Updated:

Platform:

Replies:

150085 Dec 19,2019 05:39 PM UTC Aug 18,2020 09:28 AM UTC Blazor 21
loading
Tags: PDF Viewer
Matthew
Asked On December 19, 2019 05:39 PM UTC

Hi,

Got a strange problem when my application is deployed to my web server.
When opening the PDF Viewer I get the following Error:

ejs.interop.min.js:1 Unexpected token T in JSON at position 0
SyntaxError: Unexpected token T in JSON at position 0
    at JSON.parse (<anonymous>)
    at e.loadRequestHandler.onSuccess (https://cdn.syncfusion.com/ej2/17.4.39/dist/ej2.min.js:10:9101404)
    at e.successHandler (https://cdn.syncfusion.com/ej2/17.4.39/dist/ej2.min.js:10:9239995)
    at Object.ioSuccessHandler (https://cdn.syncfusion.com/ej2/17.4.39/dist/ejs.interop.min.js:1:20011)
    at https://dev.medco.awesomesource.dev/_framework/blazor.server.js:8:31421
    at new Promise (<anonymous>)
    at e.beginInvokeJSFromDotNet (https://dev.medco.awesomesource.dev/_framework/blazor.server.js:8:31390)
    at https://dev.medco.awesomesource.dev/_framework/blazor.server.js:1:19202
    at Array.forEach (<anonymous>)
    at e.invokeClientMethod (https://dev.medco.awesomesource.dev/_framework/blazor.server.js:1:19173)

I do not get this error when running on my development machine an debugging from Visual Studio. I am referencing the latest version of everything.
Any Ideas if I am perhaps missing a dependency on my web server - but I don't think I am as this did work with the previous version of Syncfusion.
 I am referencing the javascript files via your CDN

...
<link rel='nofollow' href="https://cdn.syncfusion.com/ej2/17.4.39/material.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/ej2/17.4.39/dist/ej2.min.js"></script>
<script src="https://cdn.syncfusion.com/ej2/17.4.39/dist/ejs.interop.min.js"></script>
...


Code as follows: ViewPDF.Razor

@using Medco.Models
@using Medco.Models.ViewModels
@using Syncfusion.EJ2.Blazor.Calendars
@using Syncfusion.EJ2.Blazor.Popups
@using Syncfusion.EJ2.Blazor.DropDowns
@using Syncfusion.EJ2.Blazor.Inputs
@using Syncfusion.EJ2.Blazor.PdfViewerServer

@if (DocumentPath != null)
{
    <EjsPdfViewerServer DocumentPath="@DocumentPath" Width="100%" Height="850px"></EjsPdfViewerServer>
}

@code {
    [Parameter] public string DocumentPath { get; set; }

}


And the code which sets the DocumentPath parameter is as follows (it is a byte array converted to base 64 string) : ViewPDFDialog.razor

@using Medco.Models
@using Medco.Models.ViewModels
@using Syncfusion.EJ2.Blazor.Calendars
@using Syncfusion.EJ2.Blazor.Popups
@using Syncfusion.EJ2.Blazor.DropDowns
@using Syncfusion.EJ2.Blazor.Inputs
@using Syncfusion.EJ2.Blazor.PdfViewerServer

<EjsDialog @ref="DialogObj" Width="100%" Height="100%" ShowCloseIcon="true" IsModal="true" @bind-Visible="_dlgVisible">
    <DialogTemplates>
        <Header>@DialogTitle</Header>
        <Content>
            <ViewPDF DocumentPath="@DocumentPath"></ViewPDF>
        </Content>
    </DialogTemplates>
</EjsDialog>


@code {
    [Parameter] public AssignmentData AssignmentData { get; set; }
    public string DialogTitle { get; set; }
    public string DocumentPath { get; set; }
    private bool _dlgVisible = false;
    protected EjsDialog DialogObj;

    [Parameter] public EventCallback OnClose { get; set; }

    public void ShowDialog(byte[] pdfData, string dialogTitle)
    {
        DocumentPath = null;
        StateHasChanged();
        DialogTitle = dialogTitle;
        DocumentPath = "data:application/pdf;base64," + Convert.ToBase64String(pdfData);
        StateHasChanged();
        DialogObj.Show(true);
    }
}

As stated above, this works perfectly fine on my development machine, but throws the JS error when deployed to my web server.


Akshaya Arivoli [Syncfusion]
Replied On December 20, 2019 09:42 AM UTC

Hi Matthew, 

Thank you for contacting Syncfusion support. 

We have tried deploying the sample with IIS but we are unable to reproduce the reported issue with the provided details. We have shared the sample in which we have tried to reproduce the issue in the below link, 


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

Regards, 
Akshaya 


Matthew
Replied On December 20, 2019 10:41 AM UTC

Hi Akshya,

I will give your sample a go - I'm pretty sure the issue is something to do with my hosting enironment, I was just hoping the error message may have pointed as to what is incorrect in my hosting environment.

Thanks

Akshaya Arivoli [Syncfusion]
Replied On December 23, 2019 06:45 AM UTC

Hi Matthew, 
 
Thank you for your update. Please try with the provided sample in your hosting environment and revert us with more details about your issue, modified sample and the hosting environment details if you are still facing the issue. These details will be helpful for us to investigate further and assist you better. 
 
Regards, 
Akshaya 


Matthew
Replied On December 23, 2019 11:24 AM UTC

Hi,

I've tried your sample and get the same result:


I have built and deployed your sample application with no changes.
You can see for yourself at https://pdftest.medco.awesomesource.dev

This is definitely a hosting environment issue - it's just a case of working out what's wrong.

It's Windows Server 2012 R2, IIS v8.5 and I have the .NetCore 3.1 SDK installed

If you want to know any more details about the environment, please let me know.

NKOUAMBIA CHIMENE
Replied On January 16, 2020 08:27 PM UTC

Hi,
The same issue for me as Matthew on a Nginx Centos Server, on my dev post every thing work but nothing on server.

Thanks,
Chimène NK.

Matthew
Replied On January 16, 2020 08:45 PM UTC

Hi Nkouabia,

The only thing I'd say is different for my deployment is that I am using Azure DevOps (MSBuild) for build & deploy. However it seems there is some dependceny somewhere missing, causing the problem. Something is missing in the nuget restore, or there is some MS Windows windows native dependency causing some kind of issue.

Mohan Selvaraj [Syncfusion]
Replied On January 17, 2020 01:29 PM UTC

Hi Matthew,  

We are using Pdfium rendering engine for robust rendering in our PDF Viewer, it will generate the Pdfium dll during the run time (i.e, on loading the document). We suspect that due to the write access permission is denied in the production environment the reported issue may occurred and so can you please try copying the below provided pdfium.dll inside the folder(bin\Debug\netcoreapp2.1) in the production environment to resolve the issue.  
 


Regards, 
Mohan S 


NKOUAMBIA CHIMENE
Replied On January 20, 2020 05:36 PM UTC

Hello Team!
I apply the given solution but it not work, as i was saying on my dev post everything work well, but after deploy on my linux serveur(Nginx Centos) I have the error and nothing show.

On my dev post I have the file .\bin\Debug\netcoreapp3.1\x64\pdfium.dll
but in the relase folder .\bin\Release\netcoreapp3.1\linux-x64 the folder x64 or the dll doesn't exist, has the last answer said I try several thing but none of them works
1- Copy manually the x64 folder in my deploy folder on server 
2- Copy the pdfium.dll in the root folder
3- Create the folder bin\Debug\netcoreapp2.1 and copy the dll into it (I also rename the folder bin\Debug\netcoreapp3.1)
I always give the 777 right to folder and file but nothing change

Is ther any other thing I can Try? 

Thanks,
Chimène NK.

Matthew
Replied On January 20, 2020 07:19 PM UTC

Hi,

I can confirm copying the pdfium.dll file to the deployment folder does not resolve the issue.

Thanks

Akshaya Arivoli [Syncfusion]
Replied On January 21, 2020 01:54 PM UTC

Hi Matthew, 

We have found that in Linux docker container the library libpdfium.so does not refer correctly. We are working to resolve this by exposing the ReferencePath property to refer the location of libpdfium.so in our source and we will update you the details. Meantime, can you please check the below steps from your side and confirm whether the issue is resolved or not? 

STEP1: Download the libpdfium.so from the following link and include it in our PDF Viewer service project 

STEP2: Add the following Docker command in your docker file to copy the libpdfium.so files in the published directory  
              RUN cp -r "libpdfium.so" /app/publish 

Please let us know if you have any concerns about this. 

Thanks, 
Akshaya 


NKOUAMBIA CHIMENE
Replied On January 23, 2020 02:23 PM UTC

Hello Team,

I'm not working with the Container so I try this step to include the files in my project but nothing work at all 
1- On my developpement post(Windows10) I copy the file libpdfium.so into the folder  MyApp\bin\Release\netcoreapp3.1\linux-x64\libpdfium.so (I even copy it in the MyApp\bin\Debug\netcoreapp3.1\libpdfium.so) I also copy the pdfium.dll in those folder just in case
2. I publish my project then I find out that the  libpdfium.so is not in release folder(even the pdfium.dll)
3. I copy it manually in the app folder on my linux server in but still have the same error
Just to remind every thing works on my developpement post

Have I missing something ?

Thanks,
Chimène NK.

Akshaya Arivoli [Syncfusion]
Replied On January 24, 2020 12:03 PM UTC

Hi NKOUAMBIA , 

We have analyzed further on this and found that some library dependencies of libpdfium.so are missing in your linux environment. To resolve this issue, you have to execute the following command.  

RUN apt-get update \  
    && apt-get install -y --allow-unauthenticated \  
        libc6-dev \  
        libgdiplus \  
        libx11-dev \  
        curl \  
        vim \  
        supervisor \  
        procps  
  

Please let us know if you have any concerns about this.  

Regards, 
Akshaya 


Matthew
Replied On January 24, 2020 09:05 PM UTC

Hi Matthew, 

We have found that in Linux docker container the library libpdfium.so does not refer correctly. We are working to resolve this by exposing the ReferencePath property to refer the location of libpdfium.so in our source and we will update you the details. Meantime, can you please check the below steps from your side and confirm whether the issue is resolved or not? 

STEP1: Download the libpdfium.so from the following link and include it in our PDF Viewer service project 

STEP2: Add the following Docker command in your docker file to copy the libpdfium.so files in the published directory  
              RUN cp -r "libpdfium.so" /app/publish 

Please let us know if you have any concerns about this. 

Thanks, 
Akshaya 


Hi Akshaya,

I'm working on windows all the way. No Linux involved.
What I can tell you is that in my local build & deploy, pdfium.dll does get added to the x64 platform folder.


But for the customer system deployment, I am using Azure DevOps for build & Deploy, and the supporting library does not get inculded, and even adding the dll manually to the deployment folder does not work.


Rob Marshall
Replied On January 24, 2020 11:22 PM UTC

I was running into a similar issue testing PDFviewer with a web forms application.  

Would run fine debugging on my dev machine, but running on 2012 R2 was failing with:
Access to the path 'C:\inetpub\...\bin\Pdfium\x64\' is denied.

In the bin folder Pdfium was not present on the server after deploying.  

I found by granting Full access rights to the AppPool account the app was running on to the \bin folder, it then created the missing files on my next run and then worked.

Akshaya Arivoli [Syncfusion]
Replied On January 27, 2020 12:07 PM UTC

Hi Matthew, 

Thank you for your update 

Can you please place the Pdfium dll  inside both x64 and x86 folders and copy it in your production environment and also in your published folder. Please try it and revert us with more details about your issue if you still have concerns. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya 


matthias
Replied On March 19, 2020 03:44 AM UTC

Hi, any news on this issue? I have the same problem. Please give us a short update. Thx

Akshaya Arivoli [Syncfusion]
Replied On March 19, 2020 12:00 PM UTC

Hi Matthias , 

Based on the provided details we suspect that the write access permission is denied so the exception is thrown. We are using Pdfium rendering engine for robust rendering in our PDF Viewer, it will generate the Pdfium dll during the run time (i.e, on loading the document. So can you please try copying the below provided pdfium.dll inside the folder(bin\Debug\netcoreapp2.1) in the production environment to resolve the issue. Place the Pdfium dll  inside both x64 and x86 folders. 


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.  
  
Please try this and revert us with more details if you are still facing the issue and confirm us whether you are hosting the application in Windows or Linux environment, error details and the sample. These details will be helpful for us to investigate further and assist you better.  

Regards, 
Akshaya 


Sean Hannan
Replied On August 10, 2020 02:36 AM UTC

Hi Syncfusion support,

I've been having the same problem and would appreciate some additional clarification on what needs to be done. The PDF file is generated on the fly using Syncfusion PDF components and does generate properly, as I can email it and download it fine, I just can't see it in the viewer, the eternal loading wheel issue.

The error message I get:

ejs.interop.min.js:1 Unexpected token T in JSON at position 0
SyntaxError: Unexpected token T in JSON at position 0
    at JSON.parse (<anonymous>)
    at e.loadRequestHandler.onSuccess (https://cdn.syncfusion.com/ej2/17.4.55/dist/ej2.min.js:10:9477128)
    at e.successHandler (https://cdn.syncfusion.com/ej2/17.4.55/dist/ej2.min.js:10:9623776)
    at Object.ioSuccessHandler (https://cdn.syncfusion.com/ej2/17.4.55/dist/ejs.interop.min.js:1:21449)
    at https://<server>/_framework/blazor.server.js:8:31619
    at new Promise (<anonymous>)
    at e.beginInvokeJSFromDotNet (https://<server>/_framework/blazor.server.js:8:31587)
    at https://<server>/_framework/blazor.server.js:1:20052
    at Array.forEach (<anonymous>)
    at e.invokeClientMethod (https://<server>/_framework/blazor.server.js:1:20022)

I'm working on a Ubuntu/Linux environment on Azure.

What I've done so far:
  • Used the Syncfusion.EJ2.Blazor.PdfViewerServer.Linux package, version 17.4.0.55
  • Put the pdfium dll file into the 'x64\' folder
  • Made the 'x64\' folder have 777 permissions
  • Put the libpdfium.so file into the 'x64\' folder
  • Made both the files have 777 permissions
  • Put the libpdfium.so file into the runtimes/linux-64/native directory
  • Made the runtimes, linux-64 and native folders have 777 permissions
  • Put the libpdfium.so file into the site's folder with 777 permissions
  • Put the pdfium.dll file into the site's folder with 777 permissions
  • Installed and updated the libc6-dev \ libgdiplus \ libx11-dev \ curl \ vim \ supervisor \ procps packages
Any ideas? The error is hard to debug as there are no error messages or logs that I can examine, and I believe I have exhausted the various options that have been listed here so far.

Thank you for your time and attention.

Akshaya Arivoli [Syncfusion]
Replied On August 11, 2020 12:34 PM UTC

Hi Sean , 

Thank you for contacting Syncfusion support. 
Please upgrade your project to your project to the latest version using the below link, because we have modified the control initialization in our latest version, 

Also 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 set the LD_LIBRARY_PATH=/lib64/  before installing the libpdifum,so dependecise. 

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 this and if you still have concerns, please revert us with more details about your issue, console error , network tab response data and simple project. These details will be helpful for us to investigate further and assist you better.   


Regards, 
Akshaya 



Sean Hannan
Replied On August 17, 2020 04:55 AM UTC

Hi Ashaya,

Running that command in linux causes a number of errors, but I can report that updating to PdfViewerServer 18.2.0.48 and setting the LD_LIBRARY_PATH seems to have corrected the issue for now.

Akshaya Arivoli [Syncfusion]
Replied On August 18, 2020 09:28 AM UTC

Hi Sean , 

Thank you for your update. We are glad to know that the issue is resolved. Please revert us if you need any further assistance.  

Regards, 
Akshaya  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon