JsPDF - Not allowed to navigate top frame to data URL

后端 未结 14 2195
Happy的楠姐
Happy的楠姐 2020-11-27 02:53

After updating Google Chrome, the report jsPDF in a new Window does not work any more.

The console shows the message:

Not allowed to navigate

14条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 03:50

    As chrome removed its support for - Top-frame navigation. Luckily jsPDF has an API - "save()", which offers the same functionality as doc.output('datauri')

    Below is the example implementation of save()

    var doc = new jsPDF();
    doc.addImage(imgData, 'JPEG', 0, 0, 300, 160);    
    doc.save('fileName.pdf');
    

    save(filename, options) → {jsPDF|Promise}

    Saves as PDF document. An alias of jsPDF.output('save', 'filename.pdf'). Uses FileSaver.js-method saveAs. Refer JSPDF documentation for more information -

提交回复
热议问题