从pdf-blob创建pdf

时间:2015-05-16 11:31:25

标签: jspdf

是否可以从我的数据库中存储的pdf创建pdf-blob文档?类似的东西:

function saveDatabaseBlob (blob) {
    var doc = new jsPDF("portrait", "mm", "a4", "compressPdf");
    doc.saveAs(blob, 'ZZZ.pdf');
}

1 个答案:

答案 0 :(得分:0)

尝试

var a = document.createElement('a');
var file = new Blob(blob, { type : 'application/octet-stream' });
a.href = window.URL.createObjectURL(file);
a.download = 'file_output.pdf'; 
a.click(); //for download 

使用Blob https://developer.mozilla.org/en-US/docs/Web/API/Blob