Pdf viewer server not load

Hi Support,
i'm using Blazor server and and your 19.1.57 component suite.
I have this problem:
I have some pdf files that i need to load using Load method passing the Base 64 string.
This is my code
byte[] byteArray = System.IO.File.ReadAllBytes(@"c:\temp\2.pdf");
base64String = Convert.ToBase64String(byteArray);
await viewer.Load("data:application/pdf;base64," + base64String, "");
//await viewer.Load(@"c:\temp\2.pdf", "");
If i use the base64 loading strign string, file does not load and i have a server - side error... If instead i use the commented line using physical path, it works smoothly!
I attach the PDF since not all pdfs shows this problem. Please try with this one
Thank you
Daniele


Attachment: 2_36d158c0.zip

5 Replies 1 reply marked as answer

VS Vasugi Sivajothi Syncfusion Team May 31, 2021 09:53 AM UTC

Hi Adriano, 
 
Thank you for contacting Syncfusion support. 
 
We have tried to reproduce the reported issue with the provided document but were unable to reproduce it.  
 
We have shared the sample in which we have tried to reproduce the issue. Please refer to the below code snippet and sample. 
 
Code Snippet: 
 
 
<SfButton @onclick="clicked">Load Document</SfButton> 
 
public void clicked() 
    { 
        byte[] byteArray = System.IO.File.ReadAllBytes("wwwroot/Data/2.pdf"); 
        string base64String = Convert.ToBase64String(byteArray); 
        Viewer.Load("data:application/pdf;base64," + base64String, null); 
    } 
 
 
 
 
 
 
 
Kindly try the sample we have provided and let us know if the issue resolves or not. If not, kindly share the error details about your issue. This will be helpful to investigate further and provide the solution at the earliest. 
 
 
Regards, 
Vasugi 



AD Adriano June 1, 2021 09:28 AM UTC

Hi Vasugi,
i figured out the issue, i simply forgot the  .AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; });
So, when the pdf was bigger i had the issue.

Another small thing... i 'm not able to set/specify the download file name. Seems that components ignore the porperty....
Could you kindly give me an example for that?

Thanks
     Daniele


VS Vasugi Sivajothi Syncfusion Team June 2, 2021 10:49 AM UTC

Hi Adriano,  
 
Thank you for the update. 
 
We are glad to know that the issue is resolved. A code and the sample are shared below to change the download file name with the DownloadFileName API. Please refer to the below details. 
 
Code Snippet: 
 
<SfPdfViewerServer @ref="Viewer" DownloadFileName="@DownloadFileName"> 
   <PdfViewerEvents Created="LoadDocument"></PdfViewerEvents> 
</SfPdfViewerServer> 
 
public void LoadDocument() 
    { 
        byte[] byteArray = System.IO.File.ReadAllBytes("wwwroot/Data/2.pdf"); 
        string base64String = Convert.ToBase64String(byteArray); 
        Viewer.Load("data:application/pdf;base64," + base64String, null); 
        DownloadFileName = "Syncfusion.pdf"; 
    } 
 
 
Kindly try this and let us know if you have any concerns about this. 
 
Regards, 
Vasugi. 


Marked as answer

GD Gianluca Dora April 9, 2022 10:38 AM UTC



VS Vasugi Sivajothi Syncfusion Team April 11, 2022 06:47 AM UTC

Hi G Dora,


We have breaking changes in the latest version V20.1.0.47. So, we suggest you enable JavaScript isolation by setting IgnoreScriptIsolation as false while adding the Syncfusion Blazor service using AddSyncfusionBlazor().


Code Snippet in a startup.cs file.


 

services.AddSyncfusionBlazor(options => { options.IgnoreScriptIsolation = false; });

 


Modified Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorSample2100238880


For more information, please refer to the below UG link.

https://blazor.syncfusion.com/documentation/release-notes/20.1.47?type=all#breaking-changes



Kindly try this and let us know if this helps you.


Regards,

Vasugi.


Loader.
Up arrow icon