并非列中的所有数据都显示在生成的PDF中

时间:2018-06-30 16:49:44

标签: angular jspdf jspdf-autotable

我的表格中有12列数据。但是12列中只有7列被捕获并生成为PDF。

请参见屏幕截图中的pdf示例输出:(它应返回12列数据)

enter image description here

这是我的代码:(我使用的是角度5)

var doc = new jsPDF('p', 'pt');
var res = doc.autoTableHtmlToJson(document.getElementById("export- 
buttons-table"));
doc.autoTable(res.columns, res.data, {
  margin: {top: 40, horizontal: 10},
  startY: false,
  pageBreak: 'auto',
  tableWidth: 'wrap',
  showHeader: 'everyPage',
  tableLineColor: 200,
  tableLineWidth: 0,
  styles: {overflow: 'linebreak', font: 'arial', fontSize: 10, cellPadding: 8},
});

doc.save(this.filename + 'pdf');

1 个答案:

答案 0 :(得分:1)

我自己解决了这个问题:)

请在下面查看我的源代码:

exportToPdf(){
  var doc = new jsPDF(this.pdfOrientation, 'pt', this.pdfFormat);
  var res = doc.autoTableHtmlToJson(document.getElementById("export-buttons- 
  table"));
  doc.autoTable(res.columns, res.data, {
    margin: {top: 40, horizontal: 10}, startY: false, theme: 'grid', pageBreak: 
   'always', tableWidth: 'auto', columnWidth: 'wrap', showHeader: 'everyPage',
    tableLineColor: 200, tableLineWidth: 0,
    columnStyles: {
    0: {columnWidth: 'auto'}, 1: {columnWidth: 'auto'}, 2: {columnWidth: 'auto'}, 3: 
        {columnWidth: 'auto'}, 4: {columnWidth: 'auto'},
    5: {columnWidth: 'auto'}, 6: {columnWidth: 'auto'}, 7: {columnWidth: 'auto'}, 8: 
        {columnWidth: 'auto'}
    },
    headerStyles: {theme: 'grid'},
    styles: {overflow: 'linebreak', columnWidth: 'wrap', font: 'arial', fontSize: 10, 
    cellPadding: 8, overflowColumns: 'linebreak'},
    });
  doc.save(this.filename + '.pdf');
 }

output