【问题标题】:How to put multiple horizontally tables in jsPDF-autotable如何在jsPDF-autotable中放置多个水平表
【发布时间】:2022-09-28 21:33:17
【问题描述】:

我是 JSPDF 的新手,我不明白如何让 2 个表格彼此相邻。

我已经尝试了 examples/examples.js 中的多个示例

var doc = new jspdf.jsPDF(\'p\',\'pt\',\'a4\'); 
var pageNumber = doc.internal.getNumberOfPages()
doc.autoTable({
  startY: 240,
  showHead: \'firstPage\',
  html:   \'#table\',
  styles: {  overflow: \'hidden\'},
  margin: { left: 107 },
});

doc.setPage(pageNumber)

doc.autoTable({
  startY: 240,
  showHead: \'firstPage\',
  html:   \'#table\',
  styles: { overflow: \'hidden\'},
  margin: { right: 107 },
});

我想它只会在水平方向上以 107 的边距显示它们

代替 :

我不明白我缺少什么,因为我复制了示例并用 html 表替换了数据。

    标签: jspdf jspdf-autotable


    【解决方案1】:
     generatePdf () {
        let doc = new jsPDF();
        autoTable(doc,{
          head:[['Id','Name','Email','Profile']],
          body:[
            [1,'Nadim','nadim@gmail.com','Head'],
            [2,'Nadim','nadim@gmail.com','Head'],
            [3,'Nadim','nadim@gmail.com','Head'],
            [4,'Nadim','nadim@gmail.com','Head']
            ],
    
          startY: 240,
          showHead: 'firstPage',
         
          styles: {
             overflow: 'hidden',
    
        },
          margin: {
            left: 107
          },
        });
    
    
      autoTable(doc,{
          head:[['Id','Name','Email','Profile']],
          body:[
            [1,'Nadim','nadim@gmail.com','Head'],
            [2,'Nadim','nadim@gmail.com','Head'],
            [3,'Nadim','nadim@gmail.com','Head'],
            [4,'Nadim','nadim@gmail.com','Head']
            ],
    
          startY: 240,
          showHead: 'firstPage',
          **strong text**
          styles: {
             overflow: 'hidden',
    
        },
          margin: {
            left: 107
          },
        });
    
     
        doc.output('dataurlnewwindow');
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多