Hi,I have a pdf viewer as follows:<SfPdfViewerServiceUrl="/report/viewreport"Height="100%" Width="100%"></SfPdfViewer>And my controller is like this:[HttpGet("viewreport")]public async Task<IActionResult> ViewReport(){XtraReport1 rpt = new XtraReport1();MemoryStream ms = new MemoryStream();await rpt.ExportToPdfAsync(ms);return new FileContentResult(ms.GetBuffer(), "application/pdf");}It only displays a blank viewer, how to do it correctly?Thank you.
Hi Martin,Thanks for contacting Syncfusion support.Syncfusion PDF Viewer control is both server and client-side oriented. So, we need to create the own web service and add the web service URL in the serviceUrl property of our client-side for further processing in the PDF document. We have shared the simple sample for your reference. Please refer to the below sample and documentation steps to create the web service,Client side Blazor: https://www.syncfusion.com/downloads/support/directtrac/general/ze/TestApp1778883205Web service: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Web_Service-921247804Documentation:https://www.syncfusion.com/kb/10346/how-to-create-pdf-viewer-web-service-application-in-asp-net-coreKindly try this and revert to us with more details if the provided solution is not meet your requirement.RegardsVasugi
app.UseCors(); |
Hi Martin,Thanks for the update.We have analyzed the code in the provided sample, we suspect that the reported issue occurs due to not enabling the CORS in your sample. So kindly add the below code in the startup.cs file with in (Configure) method. In our PDFViewerController.cs file, we have provided the code ([Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]) before all our action method. So that the reported issue occurs in your end.
app.UseCors();We have modified the provided sample. Please refer to the below link,Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PDFVIEWER-SAMPLE-479681280Kindly try this and revert to us with more details if you still have concerns about this.Regards,Vasugi
Hi Martin,We have modified the sample by creating our PDF Viewer inside the div element by occupying the whole div. And we have shared the sample. Kindly download the sample from the below link,Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/PDFVIEWER-SAMPLE1052733358Kindly try it and revert us, if you have any concerns about this.Regards,Dhivya.
Query |
Details |
Thank you very much for your quick response. It's working now.
I have another question, how to pass extra parameter to service like I want to send an ID.
|
Currently, we do not have support to pass extra parameter to service in blazor. However, we will analyze further on this and update you with more details on April 8, 2021.
|
Also, I want to show a loader while the pdfviewer is not shown yet to client, I used sfspinner, but it won't stop spinning even if I call HideAsync. |
We can hide or show spinner using VisibleProperty. Please refer to the below documentation,
Kindly try this and let us know if you have any concerns about this. |