2017-07-27 65 views

回答

0

您需要在瀏覽器窗口中的Blob首先打開它,並調用打印功能
我沒有測試代碼,但hopfully它會工作

var byteArray = yourDocumentBytes; 
var ua = window.navigator.userAgent; 
var msie = ua.indexOf("MSIE "); 
// This will check if the browser is IE 
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) 
{ 
var blob = new Blob(byteArray, { type: 'application/pdf' }); 
window.navigator.msSaveBlob(blob, documentName); 
} else // If another browser 
{ 
    var element = document.createElement('a'); 
    element.setAttribute('href', 'data:application/pdf;base64,' + encodeURIComponent(getBase64(byteArray))); 
    element.setAttribute('download', documentName); 
    element.style.display = 'none'; 
    document.body.appendChild(element); 
    element.click(); 
    document.body.removeChild(element); 
} 
// and call print function like this 
window.print() 
相關問題