如何解决使用pdfmake在pdf文件中显示数组元素
在我的 angular 项目中,我到达最后一页,其中包含一个包含从数据库中获取的数据的数组。 如何通过pdfmake将它们导入pdf?我想在第一列 interv.code 和第二列 interv.description 中显示一个表格
interv: AssociationInt[]
export class AssociationInt {
interv: Interv
price: number
details: string
export class Interv {
id: number
code: string
description: string
解决方法
在 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();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。