Can you
provide a working sample of using client side PDF Viewer in Blazor Web Assembly
asp.net core hosted app, where the server side hosts the controller for the for
PDF Viewer to perform server-side preprocessing of the PDF document to be
rendered in client-side similar what is done in https://www.syncfusion.com/kb/11063/how-to-create-the-pdf-viewer-web-service-application-in-net-core-3-0-and-above-version
Hi Gudmundur,Thank you for contacting Syncfusion support.We have created a simple PDF Viewer sample in Blazor Web Assembly asp.net core hosted app and shared the same in the below link,Please try it and revert us if any concerns.
Regards,Akshaya
Hi -
Thank you for this demo application, this is exactly what I was trying to do.
There is one piece of your demo app that I am having trouble reproducing in my app.
In the SfPdfViewer client-side element, you are able to just reference the api controller in the ServiceUrl attribute:
ServiceUrl="/PdfViewer"
When I do this I get an error that " Only 'http' and 'https' schemes are allowed. Parameter name: requestUri"
For some reason that I cannot figure out, the ServiceUrl is not adding the entire base uri to the api call. However when I manually define the base uri in the ServiceUrl attribute it works fine:
ServiceUrl="https://localhost:44396/PdfViewer"
Can you give me any direction as to what I'm missing to add this feature to my application?
Also - When using the pdf viewer on a WASM app that uses Authorization, there is an error generated because of the access tokens that are required.
Microsoft.AspNetCore.Components.WebAssembly.Authentication.AccessTokenNotAvailableException: ''
Is there a way to configure this in the PDF viewer?
Thanks
|
Query |
Details | |
|
Thank you for this demo application, this is exactly what I was trying to do.
There is one piece of your demo app that I am having trouble reproducing in my app.
In the SfPdfViewer client-side element, you are able to just reference the api controller in the ServiceUrl attribute:
ServiceUrl="/PdfViewer"
When I do this I get an error that " Only 'http' and 'https' schemes are allowed. Parameter name: requestUri"
For some reason that I cannot figure out, the ServiceUrl is not adding the entire base uri to the api call. However when I manually define the base uri in the ServiceUrl attribute it works fine:
ServiceUrl="https://localhost:44396/PdfViewer"
Can you give me any direction as to what I'm missing to add this feature to my application?
|
Thank you for your update. We were able to reproduce the reported issue that the document is not loading in the Blazor Hosted Application. We have already logged this as defect and the fix for the changes will be included in our upcoming weekly NuGet release on December 15, 2021. You can track the status using the below feedback link,
| |
|
Also - When using the pdf viewer on a WASM app that uses Authorization, there is an error generated because of the access tokens that are required.
Microsoft.AspNetCore.Components.WebAssembly.Authentication.AccessTokenNotAvailableException: ''
Is there a way to configure this in the PDF viewer?
|
You can configure the token on the server side. To deal with this authentication in the PDF Viewer client we have exposed a property ajaxRequestSettings to add the header value for each request of PDF Viewer. We have shared the code snippet and sample for your reference.
Code snippet:
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorWebAssembly-814305460
Kindly try this and revert us, if you have any concerns.
|
Hi Austin,
Sorry for the inconvenience. The fix was not included in our latest weekly NuGet release. It will be available in our upcoming Volume 4 main release which is expected to be rolled out on December 17th, 2021.
Regards,
Dhivya.
Will you create a "PDF Viewer in Blazor Web Assembly asp.net core hosted" app that works with net6.0?
The app that you created for net5.0 doesn't work when I update it to net6.0.
https://www.syncfusion.com/downloads/support/forum/158750/ze/blazor-pdfviewer-wasm-2116550555
After changing PDFViewerFeatures.razor DocumentPath="Blazor_Succinctly.pdf" instead of DocumentPath="PDF_Succinctly.pdf" the pdf file displayed correctly in net5.0.
From: <SfPdfViewer ServiceUrl = "/PdfViewer" DocumentPath="PDF_Succinctly.pdf" Height="500px" Width="750px">
To: <SfPdfViewer ServiceUrl = "/PdfViewer" DocumentPath="Blazor_Succinctly.pdf" Height="500px" Width="750px">
When I set the app to use net6.0 and update the NuGet packages (see below), the pdf doesn't display. When I set breakpoints in PdfViewerController.cs on the constructor and on Load, the breakpoints are never reached.
Your app using net5.0:
<TargetFramework>net5.0</TargetFramework>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
<PackageReference Include="Syncfusion.Blazor.PdfViewerServer.Windows" Version="18.4.0.48" />
</ItemGroup>
When I change it to work with net6.0:
<TargetFramework>net6.0</TargetFramework>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.5" PrivateAssets="all" />
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
<PackageReference Include="Syncfusion.Blazor.PdfViewerServer.Windows" Version="20.1.0.57" />
</ItemGroup>
Another problem I am having with your app is when I add PdfViewerController.cs to my project, swagger returns an error when trying to display the API's. The error message is:
Failed to load API definition.
Fetch error
response status is 500 https://localhost:7183/swagger/v1/swagger.json
Do you have any idea what can be done so it works with swagger?
Thanks
I am facing the same issue ever since I upgraded my project to .net 6.0, Blazor PDF viewer not working Blazor WASM hosted Application in Linux, followed all the steps from missing Linux packages to Pdfium, still I get "Web Service Not running". However the same runs perfectly in Windows
Hi Don/Muhammad,
We are working on your queries and we will update further details on June 2, 2022.
Regards,
Shamini
Hi Team,
We regret the delay. Currently, we are checking the reported issues with the provided details. We will analyze further on this and update you with more details on or before June 6, 2022.
Regards,
Vasugi.
Hi Don/Muhammad,
We have created the simple Blazor PDF Viewer hosted sample with swagger configuration and it can be downloaded from the following link.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/blazor-pdfviewer1270477668
Kindly refer to the below UG documentation to resolve the PDFIUM issue.
https://blazor.syncfusion.com/documentation/pdfviewer/how-to/unexpected-token
If you are still facing any issues, please revert to us with more details like error details, network tab response details, and a simple issue reproducing sample to replicate the issue at our end and provide a prompt solution at the earliest.
Regards,
Shamini
The app that you provided works great using version 20.1.0.60 of the components.
It stops working when using version 20.2.0.43 of the components. Once again, it no longer calls the constructor in PdfViewerController.cs. When trying to view a pdf file, the website becomes unresponsive unless you manually change the URL to a valid page.
What was changed so it is no longer working?
Will you please create another app where it works with the most recent version of you nightly NuGet packages?
Thank you for your help
Hi Don,
We have checked the sample uploaded already and find that it works proper with latest NuGet version (v20.2.0.43). We have modified the NuGet version in the older sample to get this work and have shared the modified sample for your reference. Kindly try this and revert to us if you have any concerns.
Sample Link - https://www.syncfusion.com/downloads/support/directtrac/general/ze/blazor-pdfviewer_Sample518432405.zip
Regards,
Sinthiya K
Its working in Development Environment after publish its not work in production environment. please find the screenshot
Hi Vijaymohan,
On checking in our online sample it works fine for us.
Kindly find the online sample which we checked - https://blazor.syncfusion.com/demos/pdf-viewer/default-functionalities?theme=fluent
Kindly try it in our online sample and revert to us with more details to replicate the issue.
Regards,
Visvesvar K V