简体   繁体   English

JSPDF:如何在 jsPDF 中编码 blob?

[英]JSPDF : how encode blob in jsPDF?

I am using jsPDF() And I want to present a document, I have the value BASE64 And now I want to do a BLOB and return to normal view How can I do this with JSPDF?我正在使用 jsPDF() 并且我想展示一个文档,我的值是 BASE64 现在我想做一个 BLOB 并返回到正常视图我如何用 JSPDF 做到这一点?

That's the code,那是代码,

 const print = () => { const myFont = ""; var doc = new jsPDF(); doc.text(20, 20, "Name " ); doc.addFileToVFS("MyFont.ttf", myFont); doc.addFont("MyFont.ttf", "MyFont", "normal"); doc.output("dataurlnewwindow"); };

I do not know how to add the desired line我不知道如何添加所需的行

var blobPDF =  new Blob([ doc.output() ], { type : 'application/pdf'});
var blobUrl = URL.createObjectURL(blobPDF);  //<--- THE ERROR APPEARS HERE

window.open(blobUrl);  // will open a new tab

//window.open(blobUrl,'_system','location=yes'); will open a new window

This works for me.这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM