Nin*_*rni 0 javascript browser pdf byte
我收到以下 json 格式的响应
enter code here
var blob = new Blob($(this).attr('filedata'), {
type: 'application/pdf'
});
var objectURL = URL.createObjectURL(blob);
// Create an iframe to demonstrate it:
var iframe = document.createElement('iframe');
iframe.className = 'sample-iframe';
iframe.src = objectURL;
document.body.appendChild(iframe);
Run Code Online (Sandbox Code Playgroud)
上面的代码我用来显示字节数组中的pdf
这适用于 Chrome,但不适用于 IE:
// base64DataFromWebAPI comes from a Web API, in the form of base 64 string
var pdfData = base64DataFromWebAPI;
var x = window.open();
var iframe = x.document.createElement('iframe')
iframe.width = '100%'
iframe.height = '100%'
iframe.frameBorder = 0
iframe.style = "border: 0"
iframe.src = "data:application/pdf;base64, " + pdfData
x.document.body.appendChild(iframe);
Run Code Online (Sandbox Code Playgroud)
我从以下 Stack Oveflow 问题中得到它:JsPDF - 不允许导航顶部框架到数据 URL
归档时间: |
|
查看次数: |
6143 次 |
最近记录: |