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

PdfViewer loads in development but not on server


I'm trying to load a pdf from a web api using a Blazor Server Application. It works in development but not on my IIS Windows server. The pdfViewer just spins after the file binary is downloaded. I've tried loading via file and using the base64 string to no avail.

Here is the code behind.

 SfPdfViewerServer PdfViewer;



                  var responseBody = await UserInterface.GetReportData(jsonString);

                  ReportDocumentPath = "";


                   //// DocumentPath = "data:application/pdf;base64," + responseBody;

                    var filename = Path.Combine(@"C:\Temp\Blazor", DateTime.Now.ToString().Replace("-", "").Replace(":", "").Replace("/", "").Replace(" ", "")) + ".pdf";

                    byte[] bytes = Convert.FromBase64String(responseBody);

                    System.IO.FileStream stream =

                    new FileStream(filename, FileMode.CreateNew);

                    System.IO.BinaryWriter writer =

                    new BinaryWriter(stream);

                    writer.Write(bytes, 0, bytes.Length);


                    //ReportDocumentPath = filename;

                    //ReportDocumentPath = "data:application/pdf;base64," + responseBody;

                     //await PdfViewer.LoadAsync(filename);

                    PdfViewer.Load("data:application/pdf;base64," + responseBody, null);



                catch (Exception ex)


                    spinnerHidden = true;

                    loadingShow = !spinnerHidden;

                    NoMatch = ex.InnerException.ToString();



Here is the Blazor markup

<div class="m-0 m-md-2 m-lg-2">Report Viewer<SfPdfViewerServer @ref="@PdfViewer" DocumentPath="@ReportDocumentPath" Height="800px" Width="100%"></SfPdfViewerServer></div>

Attachment: report_base64_7bf2183c.zip

1 Reply

VV Visvesvar Venkatesan Syncfusion Team March 20, 2023 01:17 PM UTC

We were 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,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/LOAD_Sample_.net_6.0_v_-_20.4.42762790073.zip

Document: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PORTFO~12031110323.zip

We need your complete code snippet to load the document as a base64 string and we have provided our own code snippet below.

We were able to load the base64 String provided by you as a PDF document and we have attached the document below.

Code Snippet:

public void OnClickopen(MouseEventArgs args)


        //Reads the contents of the file into a byte array, and then closes the file.

        byte[] byteArray = System.IO.File.ReadAllBytes("wwwroot/data/HTTP Succinctly.pdf");

        //Converts the byte array in to base64 string.

        string base64String = Convert.ToBase64String(byteArray);

        //PDF document will get loaded from the base64 string.

        viewer.Load("data:application/pdf;base64," + base64String, null);




    public async Task Load()


     string base64String =

     viewer.Load("data: application / pdf; base64," + base64String, null);



Try this sample and revert to us with the following details, if you have any concerns.

  • Modified sample or share the sample in which the issue is reproduced.
  • Code snippet
  • Replicate procedure
  • Conform the client and server-side packages are the latest ones.

This will be helpful for us to analyze further and provide the details.

Live Chat Icon For mobile
Up arrow icon