doc.autotable.previous 在 jsPDF 中未定义

doc.autotable.previous is undefined in jsPDF

我正在将 jspdf 与 vue 结合使用。我希望文本在添加 table 之后位于 table 之下,但我收到错误 doc.autotable.previous is undefined.

    exportPdf(){
      var doc = new jsPDF('l', 'pt');
      doc.setFontSize(20);
      doc.text(170, 20, 'Ürün Teslim Belgesi',{
        halign: 'center',
        valign: 'middle'
      });
      var vm = this;
      var columns = [
        {title: "Ürün", dataKey: 'product'},
        {title: 'Tip', dataKey: 'type'},
        {title: 'Adet', dataKey: 'piece'},
        {title: 'Tarih', dataKey: 'date'}
      ];
      doc.autoTable(
        columns, vm.products,{
          margin: {left: 35},
          headStyles: {halign: 'center', valign: 'middle'},
          theme: 'grid',
          tableWidth: 'auto',
          fontSize: 8,
          overflow: 'linebreak',
        });
      doc.setProperties({
          title: 'xxx',
          subject: 'yyy',
          author: 'ttt',
          keywords: 'qqq',
          creator: 'www'
        });
      doc.text("example text example text example text example text.", 14, doc.autoTable.previous.finalY + 10);
        doc.save('test.pdf');
      },

非常感谢您的帮助,祝您愉快。

我觉得很奇怪 - 尝试了您的代码,但我得到了 settings.styles is undefined 错误,而不是您描述的错误。您似乎混合了 Styling options and Other options

中的选项

以下代码工作正常(必须替换数据 - jspdf 1.5.3、jspdf-autotable 3.2.11):

var doc = new jsPDF("l", "pt");
  doc.setFontSize(20);
  doc.text(170, 20, "Ürün Teslim Belgesi", {
    halign: "center",
    valign: "middle"
  });
  var products = [
    { product: "Retro", type: "Shoes", piece: 1, date: "1.1.2020" }
  ];
  var columns = [
    { title: "Ürün", dataKey: "product" },
    { title: "Tip", dataKey: "type" },
    { title: "Adet", dataKey: "piece" },
    { title: "Tarih", dataKey: "date" }
  ];
  doc.autoTable(columns, products, {    
    theme: "grid",
    styles: {
      fontSize: 8,
      overflow: "linebreak"
    },
    headStyles: { halign: "center", valign: "middle" },
    tableWidth: "auto",
    margin: { left: 35 }
  });
  doc.setProperties({
    title: "xxx",
    subject: "yyy",
    author: "ttt",
    keywords: "qqq",
    creator: "www"
  });
  doc.text(
    "example text example text example text example text.",
    14,
    doc.autoTable.previous.finalY + 10
  );
  doc.save("test.pdf");