2016-07-27 109 views
0

由于我使用请求发送大量数据,因此必须使用renderAsync来使用POST。当流回来时,我用下面的JS代码打开它Jsreport渲染异步时出现格式错误的URI错误

jsreport.renderAsync(request).then(function(arrayBuffer) { 
window.open("data:application/pdf;base64," + arrayBuffer 
)};); 

但是然后错误显示。有没有其他的方法来做到这一点?

回答

1

这似乎是工作

<script> 
    jsreport.renderAsync(request).then(function(response) { 
     var uInt8Array = new Uint8Array(response); 
     var i = uInt8Array.length; 
     var binaryString = new Array(i); 
     while (i--) 
     { 
      binaryString[i] = String.fromCharCode(uInt8Array[i]); 
     } 
     var data = binaryString.join(''); 
     var base64 = window.btoa(data); 

     window.open("data:application/pdf;base64, " + base64);  
    }) 
</script> 
+0

你岩石先生。关于jsreport另一个伟大的事情是,你总是在那里给它完美的支持 –