In a ASP.Net Core 6 Blazor server application, is it possible to return a pdf file from a razor page? I'm using wkhtmltopdf to generate the pdf when requested by a user. The pdf is generated and returned as a byte array. Currently the byte array goes into a MemoryStream and a Javascript method is called which will allow the user to save the pdf to their computer. I would rather the pdf open in the web browser. Is this possible?
Button click on the razor page calls the following method.
async Task ViewPdf() {
// create the pdf writer object
Writer = WritePDF.CreateInstance();
// call wkhtmltopdf to generate the pdf
var pdf = Writer.Value.Execute();
var ms = new MemoryStream(pdf);
using var streamRef = new DotNetStreamReference(stream: ms);
await JSRuntime.InvokeVoidAsync("myApp.downloadFile", "mypdf.pdf", streamRef);
}