Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何在jspdf自动表中获取lastAutoTable的最终版本_Angular_Jspdf_Html To Pdf_Jspdf Autotable - Fatal编程技术网

Angular 如何在jspdf自动表中获取lastAutoTable的最终版本

Angular 如何在jspdf自动表中获取lastAutoTable的最终版本,angular,jspdf,html-to-pdf,jspdf-autotable,Angular,Jspdf,Html To Pdf,Jspdf Autotable,我使用的是angular 9。我需要将一个包含表格上下部分内容的html表格转换为pdf格式。我使用的是jspdf自动表格。我按照链接中的示例编写标题,然后生成表格。问题是当我需要在表格下方添加一些文本行时 我的代码如下 generatePdf(){ const doc = new jsPDF(); doc.setFontSize(18) doc.text('ATTENDANCE REPORT FOR DEPOT - '+this.depotId, 14, 22); autoTable(doc,

我使用的是angular 9。我需要将一个包含表格上下部分内容的html表格转换为pdf格式。我使用的是jspdf自动表格。我按照链接中的示例编写标题,然后生成表格。问题是当我需要在表格下方添加一些文本行时

我的代码如下

generatePdf(){
const doc = new jsPDF();
doc.setFontSize(18)
doc.text('ATTENDANCE REPORT FOR DEPOT - '+this.depotId, 14, 22);
autoTable(doc, { html: '#report-per-depot',startY: 30, });
doc.text(" ", 14, doc.lastAutoTable.finalY + 10)
doc.save('AttandancePerDepot.pdf');

}
我得到的错误是

Property 'lastAutoTable' does not exist on type 'jsPDF'.
我尝试将lastAutoTable导入为,从“jspdf autotable”导入lastAutoTable
我没有显示任何错误,但我不确定如何从中得到最终结果

  lastAutoTable(doc,{});
上面没有显示错误,但是它的返回类型是void。所以这就是我被卡住的地方。
如何获得angular 9或angular 10中的最终位置?

之所以出现此错误,是因为Typescript是一种强类型语言&lastAutoTable未在index.d.ts文件(在jsPdf节点模块下)中定义

下面是一个绕过此错误的小技巧&获取最终值

import jsPDF from 'jspdf';
import 'jspdf-autotable';
    
let finalY = (doc as any).lastAutoTable.finalY;

这对我在Angular 10项目中起到了作用,因为Typescript是一种强类型语言&lastAutoTable没有在index.d.ts文件(在jsPdf节点模块下)中定义

下面是一个绕过此错误的小技巧&获取最终值

import jsPDF from 'jspdf';
import 'jspdf-autotable';
    
let finalY = (doc as any).lastAutoTable.finalY;
这在我的Angular 10项目中对我起了作用