大家好,
我正在尝试将byte
从API转换为pdf
并打开JavaScript window.open
,但它显示了一个空白窗口。
这是我的示例代码
...
console.log(response.data) // shows byte array properly from my api
window.open("data:application/pdf;base64; " + response.data, '', "height=600, width=800");
...
我能够从API中获取我的字节,但是问题是,它没有显示在我的window.open
中。我什至已经测试了字节,并将其发送到后端的电子邮件中,PDF工作正常,而不是空白。
我不知道为什么它不会在我的客户端显示任何结果。无论如何我都在使用Google Chrome。
尝试将您的字节数组转换为base64,以这样的编码:
window.open("data:application/pdf;base64; " + System.Convert.ToBase64String(response.data), '', "height=600, width=800");