Error: The type 'SfPdfViewer' does not contain a public invokable method with [JSInvokableAttribute("GetPDFInfo")].
Hi, I've got an javascript exception , when page is loading, after upgrading version from 18.3.0.* => 18.4.0.35
The type 'SfPdfViewer' does not contain a public invokable method with [JSInvokableAttribute("GetPDFInfo")].
The type 'SfPdfViewer' does not contain a public invokable method with [JSInvokableAttribute("GetPDFInfo")].
Uncaught (in promise) Error: System.ArgumentException: The type 'SfPdfViewer' does not contain a public invokable method with [JSInvokableAttribute("GetPDFInfo")].
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.GetCachedMethodInfo(IDotNetObjectReference objectReference, String methodIdentifier)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.InvokeSynchronously(JSRuntime jsRuntime, DotNetInvocationInfo& callInfo, IDotNetObjectReference objectReference, String argsJson)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime jsRuntime, DotNetInvocationInfo invocationInfo, String argsJson)
at Object.endInvokeDotNetFromJS (blazor.server.js:1)
at e. (blazor.server.js:8)
at blazor.server.js:1
at Array.forEach ()
at e.invokeClientMethod (blazor.server.js:1)
at e.processIncomingData (blazor.server.js:1)
at e.connection.onreceive (blazor.server.js:1)
at WebSocket.i.onmessage (blazor.server.js:1)
Can you help me?
My source code is:
Can you help me?
My source code is:
@using Syncfusion.Blazor.PdfViewer
@inject NavigationManager NavigationManager
< div class="d-flex flex-fill" style="min-width:347px;">
< SfPdfViewer @ref="pdfv" Height="80vh" Width="100%" EnableDownload="false" EnableHyperlink="true"
EnableTextSelection="false" EnableToolbar="true" DocumentPath="@DocumentPath">
< PdfViewerToolbarSettings ToolbarItems="@ToolbarItems">
< /PdfViewerToolbarSettings>
< PdfViewerEvents DocumentLoaded="dl">< / PdfViewerEvents>
SfPdfViewer>
< /div>
@code {
[Parameter]
public string CurrFileId { get; set; }
private SfPdfViewer pdfv;
private string DocumentPath { get; set; }
protected void dl(LoadEventArgs args)
{
int i = 0;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await Reload();
await base.OnAfterRenderAsync(firstRender);
}
protected override async Task OnInitializedAsync()
{
//await Reload();
await base.OnInitializedAsync();
}
public async Task Reload()
{
if (!String.IsNullOrEmpty(CurrFileId))
{
string Url = String.Format("{0}api/download/{1}", NavigationManager.BaseUri, CurrFileId);
using (System.Net.WebClient webClient = new System.Net.WebClient())
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
byte[] byteArray = await Task.Run(() => webClient.DownloadData(Url));
DocumentPath = "data:application/pdf;base64," + Convert.ToBase64String(byteArray);
//await pdfv.Load(DocumentPath, null);
}
}
await InvokeAsync(StateHasChanged);
}
List ToolbarItems = new List() {
ToolbarItem.MagnificationTool,
ToolbarItem.PanTool,
};
}
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
DM
Dhivyabharathi Mohan
Syncfusion Team
January 25, 2021 10:02 AM UTC
Hi Alex,
Our blazor client side PDF Viewer control depends on server-side processing to render the PDF files, it is mandatory to set the serviceUrl property. But, you have missed the serviceUrl property. So, the issue occurs. Kindly modify the code snippet as link below. And we have shared the sample for your reference. You can create your own web service using the below documentation link:
UG Documentation: https://www.syncfusion.com/kb/10346/how-to-create-pdf-viewer-web-service-application-in-asp-net-core?_ga=2.44132452.1747577074.1611533738-921852827.1603653491
Code snippet:
|
div class="d-flex flex-fill" style="min-width:347px;">
<SfPdfViewer @ref="PdfViewer" DocumentPath="PDF_Succinctly.pdf" ServiceUrl="https://ej2services.syncfusion.com/production/web-services/api/pdfviewer" Height="500px" Width="1060px">
<PdfViewerToolbarSettings ToolbarItems="@ToolbarItems">
</PdfViewerToolbarSettings>
<PdfViewerEvents DocumentLoaded="dl"></PdfViewerEvents>
</SfPdfViewer>
</div>
|
Sample:
Kindly try it and revert us, if you have any concerns about this.
Regards,
Dhivya.
Marked as answer
AL
Alex
January 25, 2021 01:33 PM UTC
Thanks a lot, thats work correctly
AA
Akshaya Arivoli
Syncfusion Team
January 26, 2021 02:43 AM UTC
Hi Alex,
Thank you for your update. We were glad to know that the reported issue was resolved.
Regards,
Akshaya
SIGN IN To post a reply.