首页 > 解决方案 > 如何使用jspdf autotable删除表格之间的边距

问题描述

我有一个使用 jspdf 的 Angular 应用程序,但它有很多错误,尤其是在图像和空间方面,所以我开始使用 jspdf autotable,这似乎更稳定,但表格之间有边距。这是我的代码:

    const doc = new jsPDF()
    //@ts-ignore
    doc.autoTable({
        theme: 'plain',
        margin: {top: 0, bottom: 0},
        head: [[ 'Logo mecprog placeholder', {content: 'ORDEM DE SERVIÇO', styles: {fontSize: 20, lineWidth: 1}}, 'logo cliente placeholder']],
        body: [['',{content:  ordemDeServico.cod, styles: {lineWidth: 1}}, '']]
    })
      //@ts-ignore
    doc.autoTable({
        theme: 'plain',
        margin: {top: 0, bottom: 0},
        head: [[ {content:  'Cliente', styles: {lineWidth: 1}},{content:  'Data Progamada', styles: {lineWidth: 1}}, {content:  'Data Executada', styles: {lineWidth: 1}}]],
        body: [[{content:  ordemDeServico.cliente.nomeFantasia, styles: {lineWidth: 1}}, {content:  ordemDeServico.dataProgramada, styles: {lineWidth: 1}},{content: ordemDeServico.dataExecutada, styles: {lineWidth: 1}}]]
    })
    //@ts-ignore
    doc.autoTable({
        theme: 'plain',
        margin: {top: 0, bottom: 0},
        head: [[{content:  'Equipamento', styles: {lineWidth: 1}} , {content:  'Km/Hora Execução', styles: {lineWidth: 1}}, {content:  'Modelo', styles: {lineWidth: 1}}]],
        body: [[{content:  ordemDeServico.equipamento.equipamento, styles: {lineWidth: 1}},{content: this.check(ordemDeServico.quilometroExecucao), styles: {lineWidth: 1}},{content: this.check(ordemDeServico.equipamento.modelo), styles: {lineWidth: 1}}]]
    })
    //@ts-ignore
    doc.autoTable({
      theme: 'plain',
      margin: {top: 0, bottom: 0},
      head: [[{content:  'Equipamento', styles: {lineWidth: 1}} , {content:  'Km/Hora Execução', styles: {lineWidth: 1}}, {content:  'Modelo', styles: {lineWidth: 1}}]],
      body: [[{content:  ordemDeServico.equipamento.equipamento, styles: {lineWidth: 1}},{content: this.check(ordemDeServico.quilometroExecucao), styles: {lineWidth: 1}},{content: this.check(ordemDeServico.equipamento.modelo), styles: {lineWidth: 1}}]]
  })

      doc.save('table.pdf')

ordemDeServico 只是一个存储一些信息的对象,所以这并不重要,问题是即使我将边距设置为 0,表格本身也是分开的,所以我不知道该怎么办

标签: angularjspdfjspdf-autotable

解决方案


推荐阅读