Angular2 + jspdf-自动换行符不起作用
Angular2 + jspdf-autotable linebreak not working
我只想使用 溢出:"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 时它看起来像那样
尝试将 columnStyles: { text: { columnWidth: 'auto' } }
更改为 columnStyles: { comment: { columnWidth: 'auto' } }
我只想使用 溢出:"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 时它看起来像那样
尝试将 columnStyles: { text: { columnWidth: 'auto' } }
更改为 columnStyles: { comment: { columnWidth: 'auto' } }