Cannot find jsPdf name in TypeScript

My task is to print the data in a pdf file using JavaScript. So I chose jsPdf for my task and succeed. My task is to convert this print task to TypeScript. There is a new problem here. Can't find name jsPdf in TypeScriptI don’t know the reason here, because the code that was successfully run in my JavaScript could not do this when starting with TypeScript. I spent two days finding a solution for this, but failed. Contact the site, but did not find a solution. Can someone help me with this.

index.html ,

<script src="common/jspdf.min.js"></script>
<script src="common/jspdf.plugin.autotable.js"></script>
Run codeHide result

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");
            }
        };
Run codeHide result

Everything is fine at the moment, but the problem arises when I associate this with the type of 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");
         }   
        };
Run codeHide result

jsPdf() javaScript, TypeScript jsPdf.

+4
1
+4

Source: https://habr.com/ru/post/1648669/


All Articles