Server PDF Viewer Doesn't Work When Published To Azure

Hi,

I have published my site to Azure and the server side PDF server doesn't render the document, it leaves the UI with a spinning circle indefinitely.  This works fine whilst running in the development environment.

Is it supported to be published to Azure and have you come across this issue before?

Thanks

9 Replies 1 reply marked as answer

AA Akshaya Arivoli Syncfusion Team June 19, 2020 09:59 AM UTC

Hi Robert, 

Thank you for contacting Syncfusion support. 

Based on the provided details we suspect that the write access permission is denied which might the cause of the issue. We have embedded the Pdfium rendering engine in our PDF Viewer for robust rendering, so Pdfium dll will be generated on runtime within your project location.  We can resolve this by providing the write permission to your project location so that it will allow to create the pdfium dll in your project location during run time.  

There is no need to include the provided dll in your project directly. We need to place the provided pdfium dll (for windows environment) both x86 and x64 folders and refer it in your project using the ReferencePath API. Suppose if you have place the pdfium dll inside WebRootPath folder (WebRootPath -> x86->pdfium.dll and WebRootPath -> x64->pdfium.dll) then refer it using the below code, 


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 


We have also shared the steps to publish the PDF Viewer Web API application in Azure App Service from VS 




Please try it and if you still have concerns revert us with more details about your issue and console errors, if you have concerns. Else 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  


Marked as answer

RO Robert June 21, 2020 06:41 PM UTC

Hi,

Thanks for the quick response.  Could you review the below and advise what I'm doing wrong as I can't see where to put the code you mention?

To confirm I'm using the serverside component so I have no code to set it up - just markup as below:

                    <div class="form-group row">
                        <SfPdfViewerServer ID="pdfviewer" DocumentPath="@claimMediaObject.MediaEncoded" Width="100%" Height="600px" />
                    </div>


The developer tools show the following:

syncfusion-blazor.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 t.pdfViewer.serverActionSettings.loadRequestHandler.onSuccess (https://daylightgroupdemo.azurewebsites.net/_content/Syncfusion.Blazor/scripts/pdfviewer-efc2c3.min.js:1:977786)
    at t.successHandler (https://daylightgroupdemo.azurewebsites.net/_content/Syncfusion.Blazor/scripts/pdfviewer-efc2c3.min.js:1:1138802)
    at Object.ioSuccessHandler (https://daylightgroupdemo.azurewebsites.net/_content/Syncfusion.Blazor/scripts/syncfusion-blazor.min.js:1:179975)
    at https://daylightgroupdemo.azurewebsites.net/_framework/blazor.server.js:8:31421
    at new Promise (<anonymous>)
    at e.beginInvokeJSFromDotNet (https://daylightgroupdemo.azurewebsites.net/_framework/blazor.server.js:8:31390)
    at https://daylightgroupdemo.azurewebsites.net/_framework/blazor.server.js:1:19202
    at Array.forEach (<anonymous>)
    at e.invokeClientMethod (https://daylightgroupdemo.azurewebsites.net/_framework/blazor.server.js:1:19173)



AA Akshaya Arivoli Syncfusion Team June 22, 2020 12:52 PM UTC

Hi Robert , 

Thank you for your update.          

We do not have support for the ReferncePath API in PDF Viewer Server Side Blazor. It will be supported only in Client Side Blazor. As mentioned earlier, kindly place the Pdfium dll under the Bin-> Debug/Release->netcoreapp3.1 > x86& X64.  

Please try it and if you are still facing the issue, 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  



TO Tom June 23, 2020 01:38 PM UTC

Hi,

New to client side Blazor. When opeing a pdf file from local file system,. UI only show spinning circle.

I download the Pdfium.dll files.    Please provide next steps detailed instructions.   

=====

https://blazor.syncfusion.com/documentation/pdfviewer/opening-pdf-file/

@using Syncfusion.Blazor.PdfViewerServer

<SfPdfViewerServer ID="pdfviewer" DocumentPath="@DocumentPath" Width="1060px" Height="500px"/>

@code
{
   
static byte[] byteArray = System.IO.File.ReadAllBytes("wwwroot/data/PDF_Succinctly.pdf");
   
static string base64String = Convert.ToBase64String(byteArray);
   
public string DocumentPath { get; set; } = "data:application/pdf;base64," + base64String;
} ====== Thanks




MS Mohan Selvaraj Syncfusion Team June 24, 2020 11:02 AM UTC

Hi Tom, 

The SfPdfViewer control is for Blazor client-side application. This control requires server-side processing to render the PDF files through web service. So ServiceUrl is required for processing the PDF file in our PDF Viewer control . You can create a web service as mentioned here.  

<SfPdfViewer DocumentPath="PDF_Succinctly.pdf" ServiceUrl="https://ej2services.syncfusion.com/production/web-services/api/pdfviewer" Height="500px" Width="1060px" ></SfPdfViewer> 


Kindly refer the UG documentation link for more details about using the Syncfusion Blazor PDF Viewer control. 

Regards, 
Mohan S


VI Vishnu December 2, 2020 04:36 AM UTC

Hi Mohan Selvaraj,

I have a requirement to show the pdf /doc files in non-editable mode in Blazor Server application.
Could you please let me know how I can achieve this? I have tried the SfPdfViewerServer and it is not working.

Thanks & Regards
Vishnu


AA Akshaya Arivoli Syncfusion Team December 3, 2020 02:15 PM UTC

Hi Vishnu, 

Thank you for your update. 

The provided information was not clear, so can you please provide more details about your requirement and the use case. Also, confirm whether you require to restrict the adding of annotations, disabling copy text, and restrict printing and downloading. These details will be helpful for us to investigate further and assist you better. 

Regards, 
Akshaya  



VI Vishnu December 4, 2020 05:35 AM UTC

Hi Akshaya,

We have a web application developed in Blazor Server. The requirement is to show the documents to the users of the web application in non-editable format. 
  • Document formats : word & pdf
  • The user should only be a able to view the documents within the web page. 
  • The document should be read only & not downloadable by the user.
  • The document should not be downloadable
  • No print functionality

Thanks & Regards
Vishnu


AA Akshaya Arivoli Syncfusion Team December 7, 2020 12:36 PM UTC

Hi Vishnu, 
 
Please find the details of your query below, 
 
Query 
Details  
Word Document 
Set below property to “true” to restrict editing inside the document editor.  
  
  
<SfDocumentEditorContainer @ref="container" RestrictEditing=true></SfDocumentEditorContainer>  
  
Set below property in the created event to disable print, sfdt export, word export.  
  
<SfDocumentEditorContainer @ref="container" EnableToolbar=true>  
    <DocumentEditorContainerEvents Created="OnCreated"></DocumentEditorContainerEvents>  
</SfDocumentEditorContainer>  
  
@code {  
    protected void OnCreated(object args)  
    {  
        DocumentEditorModule editor = container.GetDocumentEditor();  
        editor.EnablePrint = false;  
        editor.EnableSfdtExport = false;  
        editor.EnableWordExport = false;  
    }  
 
  
 
Pdf Document  
We can disable the Download and Print functionalities of the PDF Viewer using the ToolbarSettings API. Refer to the below code and sample for the same, 
 
<SfPdfViewerServer Width="100%" Height="900px" DocumentPath="@DocumentPath" EnableTextSelection="false"  @ref="Viewer"> 
 
    <PdfViewerToolbarSettings ToolbarItems="new List<ToolbarItem> {ToolbarItem.OpenOption,ToolbarItem.PageNavigationTool,ToolbarItem.MagnificationTool, ToolbarItem.SearchOption}"></PdfViewerToolbarSettings> 
 
</SfPdfViewerServer> 
 
 
 
Kindly try it and revert us with more details about your requirement 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 


Loader.
Up arrow icon