根据问题Open PDF in new browser full window,我似乎可以使用JavaScript打开一个新窗口,其中包含一个PDF文件,代码如下:
window.open('MyPDF.pdf', '_blank');
我希望在从服务器返回时添加一个字节数组,而不是文件名来作为window.open
中的URL位置
我目前正在返回PDF文件,比如this:
Response.Clear();
Response.ContentType = "application/pdf";
Response.BinaryWrite(pdfByteArray);
Response.Flush();
有没有一种方法可以用javascript打开一个带有PDF字节数组的新窗口.
大概是这样的:
var script = "window.open('" + pdfByteArray + "', '_blank');";
ScriptManager.RegisterClientScriptBlock(Parent.Page, typeof(Page), "pdf", script, true);