【问题标题】:Angular2 + jspdf-autotable linebreak not workingAngular2 + jspdf-自动换行符不起作用
【发布时间】:2017-10-16 23:41:59
【问题描述】:

我只想在我的评论栏中使用 overflow: "linebreak" 选项这是我的代码

 var columns = [
        { title: "Date", dataKey: "date" },
        { title: "User", dataKey: "user" },
        { title: "Issue", dataKey: "issue" },
        { title: "Hours", dataKey: "hours" },
        { title: "Comment", dataKey: "comment" }

    ];
    var rows = [];
    for (let i = 0; i < this.reports.length; i++) {
        var element = {
            date: 5,
            user: 5,
            issue: 3,
            hours: 2,
            comment:"dsfsudihfusidfhsyudfyhdysuyfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
        };
        rows.push(element);
    }
    var options = {
        overflow: "linebreak"
    }
    var doc = new jsPDF();
    doc.autoTable(columns, rows, {
        startY: doc.autoTable.previous.finalY + 15,
        margin: { horizontal: 7 },
        bodyStyles: { valign: 'top' },
        styles: { overflow: 'linebreak', columnWidth: 'wrap' },
        columnStyles: { text: { columnWidth: 'auto' } }
    });
    doc.save('table.pdf');

我从他们的示例文件https://github.com/simonbengtsson/jsPDF-AutoTable/blob/master/examples/examples.js复制了这个解决方案

但是当我生成我的 pdf 时,它看起来像这样

【问题讨论】:

  • 尝试使用overflow-wrap: break-word

标签: angular jspdf jspdf-autotable


【解决方案1】:

尝试将columnStyles: { text: { columnWidth: 'auto' } } 更改为columnStyles: { comment: { columnWidth: 'auto' } }

【讨论】:

  • 它有效,谢谢。有没有办法从我的解决方案文件夹中添加一个 img,比如doc.addImage('./resources/logo.png', 'png', 10, 15, 10, 10);
猜你喜欢
  • 1970-01-01
  • 2018-08-16
  • 2012-07-29
  • 1970-01-01
  • 2018-12-19
  • 2014-03-24
  • 2015-03-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多