javascript - JsPDF - Cannot read property 'charAt' of undefined - Stack Overflow

I wrote this simple code for test the jsPDF library:const base64Img = require('base64-img');

I wrote this simple code for test the jsPDF library:

const base64Img = require('base64-img');
const JsPDF     = require('jspdf');

const LAYOUT    = base64Img.base64Sync('img/layout.png');    

$('#esporta').click( () => {
    var pdf = new JsPDF();
    pdf.addImage(LAYOUT, 'PNG', 18.25, 19.25, 190, 255);
    pdf.save('test.pdf');
});

I have a simple button that when it clicked the pdf should be generated; but I have this error:

Uncaught TypeError: Cannot read property 'charAt' of undefined at new e (/Users/th3g3ntl3man/Repository/thermowell-design/node_modules/jspdf/dist/jspdf.min.js:269) at HTMLButtonElement.$.click (export.js:62) at HTMLButtonElement.dispatch (jquery-3.3.1.min.js:2) at HTMLButtonElement.y.handle (jquery-3.3.1.min.js:2)

The line export.js:62 is the creation of the pdf: var pdf = new JsPDF();

I wrote this simple code for test the jsPDF library:

const base64Img = require('base64-img');
const JsPDF     = require('jspdf');

const LAYOUT    = base64Img.base64Sync('img/layout.png');    

$('#esporta').click( () => {
    var pdf = new JsPDF();
    pdf.addImage(LAYOUT, 'PNG', 18.25, 19.25, 190, 255);
    pdf.save('test.pdf');
});

I have a simple button that when it clicked the pdf should be generated; but I have this error:

Uncaught TypeError: Cannot read property 'charAt' of undefined at new e (/Users/th3g3ntl3man/Repository/thermowell-design/node_modules/jspdf/dist/jspdf.min.js:269) at HTMLButtonElement.$.click (export.js:62) at HTMLButtonElement.dispatch (jquery-3.3.1.min.js:2) at HTMLButtonElement.y.handle (jquery-3.3.1.min.js:2)

The line export.js:62 is the creation of the pdf: var pdf = new JsPDF();

Share Improve this question asked Dec 21, 2018 at 17:00 th3g3ntl3manth3g3ntl3man 2,1166 gold badges33 silver badges57 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

It is a reported issue. You can see here. By the time I type this message. The fix patch has not been merged yet. You can use the zip file attached here temporarily and wait for next official version released.

Extract the zip file, and copy them to node_modules/jspdf/dist, overwrite the original four files, and everything will be OK.

Today we released 1.5.3. This should fix your issue.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745042845a4607915.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信