I have gone through all the suggestions for how to take a byte array stored in SQL Server db as varbinary and display it as PDF in a Blazor website. I'm successful in ASP.Net with the aspx pages and code behind but I can't seem to find the right combination for Blazor (ShowPDF.razor and code behind ShowPDF.razor.cs) Here is what I have as variants in the code behind:
-
The aReport.ReportDocument is returning a byte array of aReport.DocumentSize from the DB
FileStreamResult GetPDF() { var pdfStream = new System.IO.MemoryStream(); this.rdb = new ReportData(); aReport = rdb.GetWithReport(1); pdfStream.Write(aReport.ReportDocument, 0, aReport.DocumentSize); pdfStream.Position = 0; return new FileStreamResult(pdfStream, new Microsoft.Net.Http.Headers.MediaTypeHeaderValue("application/pdf")); }
OR 2. direct binary array to base 64 encoding:
return Convert.ToBase64String(aReport.ReportDocument);
While those two processes return the data, I'm unable to find how to set up the razor page to show the result. I have tried: <object src="@Url.Action("GetPDF")"/> and other variants without success.
Thanks!
https://stackoverflow.com/questions/65589645/problem-showing-pdf-in-blazer-page-from-byte-array January 06, 2021 at 11:03AM
没有评论:
发表评论