Javascript 使用pdfmake在pdf文件中显示数组元素

Javascript 使用pdfmake在pdf文件中显示数组元素,javascript,html,angular,typescript,pdfmake,Javascript,Html,Angular,Typescript,Pdfmake,在我的angular项目中,我使用一个包含从数据库获取的数据的数组到达最后一页。 如何通过pdfmake将它们导入pdf?我想在第一列interv.code和第二列interv.description中显示一个表 interv: AssociationInt[] 在component.ts文件中尝试此操作 const content = [ { table: { headerRows: 1, widths: ['auto',

在我的angular项目中,我使用一个包含从数据库获取的数据的数组到达最后一页。 如何通过pdfmake将它们导入pdf?我想在第一列interv.code和第二列interv.description中显示一个表

interv: AssociationInt[]

在component.ts文件中尝试此操作

const content = [
{
          table: {
            headerRows: 1,
            widths: ['auto', 'auto'],
            body: [
              ['Code', 'Description'],
              ...this.interv.map(intervObj => 
                  [intervObj.interv.code, intervObj.interv.description]
              )
            ]
          }
        }
]
然后,使用pdfMake生成PDF

pdfMake.createPdf(content).open();

谢谢,很高兴知道。如果你愿意的话,你可以考虑投票。
const content = [
{
          table: {
            headerRows: 1,
            widths: ['auto', 'auto'],
            body: [
              ['Code', 'Description'],
              ...this.interv.map(intervObj => 
                  [intervObj.interv.code, intervObj.interv.description]
              )
            ]
          }
        }
]
pdfMake.createPdf(content).open();