Hi, i have an application with SfPDFviewer, that listen to a web service ( https://www.syncfusion.com/kb/11063/how-to-create-pdf-viewer-web-service-in-net-core-3-0-and-above )
and i'm having the following problem
any idea to solve this?
my code:
@inject IPierTarefaWebService _pdsTarefa
@inject IConfiguration Configuration
<SfPdfViewer Width="100%" Height="100%" @ref="@PDF" DocumentPath=@DocumentPath
ServiceUrl=@Configuration["PdfUrl"]></SfPdfViewer>
@code{
[Parameter]
public string ReportPath { get; set; }
public byte[] byteArray { get; set; }
public string base64String { get; set; } = "";
public string DocumentPath { get; set; }
private SfPdfViewer PDF = new SfPdfViewer();
protected override async Task OnInitializedAsync()
{
byteArray = System.IO.File.ReadAllBytes(ReportPath);
base64String = Convert.ToBase64String(byteArray);
DocumentPath = "data:application/pdf;base64," + base64String;
}
}
the service url =
"PdfUrl": "http://localhost:5000/pdfviewer"
the webservice running:
|
readonly string MyAllowSpecificOrigins = "MyPolicy";
services.AddCors(options =>
{
options.AddPolicy(MyAllowSpecificOrigins,
builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
|
i tested this and also changed the service url to https on port 5001, and that solved the reported problem, it shows the pdf correctly, but it generated probems in the unload function, when i close the pdfviewer ( SyncfusionBlazor version: 19.4.0.48)
in some cases it dosen't show the pdf(bigger than the others) and generates the error below:
i'm attaching the web service code.
Attachment: pdfviewerservice_2541979e.zip
|
[AcceptVerbs("Post")]
[HttpPost("ExportFormFields")]
[Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
[Route("[controller]/ExportFormFields")]
public IActionResult ExportFormFields([FromBody] Dictionary<string, string> jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer(_cache);
string jsonResult = pdfviewer.ExportFormFields(jsonObject);
return Content(jsonResult);
}
[AcceptVerbs("Post")]
[HttpPost("ImportFormFields")]
[Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
[Route("[controller]/ImportFormFields")]
public IActionResult ImportFormFields([FromBody] Dictionary<string, string> jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer(_cache);
jsonObject["data"] = GetDocumentPath(jsonObject["data"]);
object jsonResult = pdfviewer.ImportFormFields(jsonObject);
return Content(JsonConvert.SerializeObject(jsonResult));
}
[AcceptVerbs("Post")]
[HttpPost("Unload")]
[Microsoft.AspNetCore.Cors.EnableCors("MyPolicy")]
[Route("[controller]/Unload")]
//Post action for unloading and disposing the PDF document resources
public IActionResult Unload([FromBody] Dictionary<string, string> jsonObject)
{
//Initialize the PDF Viewer object with memory cache object
PdfRenderer pdfviewer = new PdfRenderer(_cache);
pdfviewer.ClearCache(jsonObject);
return this.Content("Document cache is cleared");
}
|
Hi,
This solved one of the problems that was generated in the console, but some errors remain. After further analysis, i found that they were generated after i updated Syncfusion Blazor from version 19.2.0.44 to 19.4.0.48 and Microsoft.AspNetCore.Components.Web from version 5.0.6 to 6.0.2.
UPDATE 1:
i tested version 19.3.0.43 and this version doesn't have error, i also tested version 19.3.0.49 and it gives me the error "Connect disconnected" in some cases, i believe the problem is between these versions.
my application is server side, and i couldn't use SfPdfViewerServer component because it generates errors in others projects in the same solution, i chose SfPdfViewer, could this be the problem?
i try to reply te error in this application test
|
services.AddServerSideBlazor().AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; });
|