Hello, there
I'm trying to load a PDF file from a Base64 code, but the component keeps loading:
The code is like this:
I checked the Base64 code to see if it wasn't broken, but it it works fine:
I'm sending a sample with the same Base64 code, it's not showing the PDF file just like in my project.
Could you please help me with this? I think I might be doing something wrong, but I'm not sure where.
Thank you
We were unable to render the component in the sample provided by you and we have provided a sample by loading the document as base64 string in the button click below.
Code Snippet:
|
public void OnClickopen(MouseEventArgs args) { string base64String = " base 64“; viewer.Load("data:application/pdf;base64," + base64String, null); } |
Rendering the base64 document in PDF Viewer component.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/LOAD_base641742664623.zip
Kindly try this and let us know if you have any concerns.
Hello, there
Thanks for the answer and the sample.
Fisrt I tried to copy the exact code from the snippet and paste in my project. The PDF file still doesn't load:
Then I checked the configurations in index.html, program.cs, startup.cs.
I added this line in my Startup.cs file:
services.AddServerSideBlazor().AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; });
I also checked if I'm dowloading the right libraries in index.html:
It seems to be all correct, still it doesn't work. My project has Client, Server, Shared (Client-server architecture), so I think that some configurations might be different from the sample you sent me.
Could you try to execute the sample I'm sending to see if there's something wrong?
Thanks,
Hello, again!
Any update about this quesqion?
Best regards,
The sample you provide is on a hosted environment basis. For hosted environment, you need to add service Url and you must use PDF Viewer alone and not PDFViewer server.
Kindly find the code changes below to render the PDF.
<SfPdfViewer Width="100%" Height="100%" @ref="viewer" ServiceUrl="https://blazor.syncfusion.com/services/production/api/pdfviewer" DocumentPath="@DocumentPath"> </SfPdfViewer> |
public string DocumentPath { get; set; } = "wwwroot/data/PDF_Succinctly.pdf"; public string Path { get; set; }
SfPdfViewer viewer; |
Kindly try it and let us know if you have any concerns.