admin管理员组文章数量:1391769
My task is to print the data's into a pdf file using JavaScript . So i selected jsPdf for my task and Succeeded in that also . My task task is to convert that print task into TypeScript . Here am facing a new problem Can't find name jsPdf in TypeScript
i don't know the reason here because the code which was successfully run in my JavaScript is failed to do that when run with TypeScript . I spended two day's for finding solution for that but failed . Refer many site's but didn't find out any solutions . Can someone Help me out from this.
index.html ,
<script src="mon/jspdf.min.js"></script>
<script src="mon/jspdf.plugin.autotable.js"></script>
My task is to print the data's into a pdf file using JavaScript . So i selected jsPdf for my task and Succeeded in that also . My task task is to convert that print task into TypeScript . Here am facing a new problem Can't find name jsPdf in TypeScript
i don't know the reason here because the code which was successfully run in my JavaScript is failed to do that when run with TypeScript . I spended two day's for finding solution for that but failed . Refer many site's but didn't find out any solutions . Can someone Help me out from this.
index.html ,
<script src="mon/jspdf.min.js"></script>
<script src="mon/jspdf.plugin.autotable.js"></script>
My Js File ,
this.print=function(){
{
var columns = [" Data","StepData","CateData","CritiData","CheckyData"];
var rows = [];
for (var i = 0 ; i<Data.length; i++)
{
rows.push([
Data[i],
StepData[i],
CateData[i],
CritiData[i],
CheckyData[i]
]);
};
var pdfsize='b2';
var doc = new jsPDF('p', 'pt',pdfsize);
doc.autoTable(columns, rows, {
theme: 'grid', // 'striped', 'grid' or 'plain'
headerStyles: {
fillColor: [12, 234, 227],
textColor: [12, 1, 1]
},
styles: {
overflow: 'linebreak',
columnWidth: 400
},
beforePageContent: function(data) {
doc.text("Process Name :"+mainData.name+" || "+"Description :"+mainData.description, 40, 30);
},
columnStyles: {
1: {columnWidth: 60}
}
});
doc.save(mainData.name+".pdf");
}
};
Every thing is good as of now , But the Problem arises when i'm tying that with type Script code ,
printData=(): any =>{
{
let rows:any = [];
for (let i:any = 0 ; i<this.Data.length; i++)
{
rows.push([
this.Data[i],
this.StepData[i],
this.CateData[i],
this.CritiData[i],
this.FrequData[i]
]);
};
let pdfsize:any='b2';
let doc :any= new jspdf('p', 'pt',pdfsize); //this line is having that error
doc.autoTable(columns, rows, {
theme: 'grid',
headerStyles: {
fillColor: [12, 234, 227],
textColor: [12, 1, 1]
},
styles: {
overflow: 'linebreak',
columnWidth: 400
},
beforePageContent: function(data) {
doc.text("Process Name :"+procName+" || "+"Description :"+procDescription, 40, 30);
},
columnStyles: {
1: {columnWidth: 60}
}
});
doc.save(this.mainData.name+".pdf");
}
};
new jsPdf () was accepted by javaScript , But TypeScript say's Can't find name jsPdf .
Share Improve this question asked Jul 29, 2016 at 14:54 Beckham_VinothBeckham_Vinoth 7213 gold badges14 silver badges40 bronze badges 1-
2
Have you tried inserting
declare var jsPDF;
at the top of your typescript file (above the printdata function). Read more here – Simon Bengtsson Commented Jul 29, 2016 at 15:09
1 Answer
Reset to default 5Suggestion from ment: Try inserting declare var jsPDF;
at the top of your typescript file (above the printdata function). Read more: http://blogs.microsoft.co.il/gilf/2013/07/22/quick-tip-typescript-declare-keyword/
本文标签: javascriptCan39t find name jsPdf in TypeScriptStack Overflow
版权声明:本文标题:javascript - Can't find name jsPdf in TypeScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744772243a2624408.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论