【发布时间】:2020-11-15 13:29:50
【问题描述】:
我正在尝试将包含换行符 (\n) 的变量传递给 PdfMake 中的表(在 Ionic 3 项目内),但生成的 PDF 不会将换行符视为新行。
table: {
headerRows: 1,
widths: ["80%", "20%"],
body: [
[
{ text: "Job Description", style: "center" },
{ text: "Total", style: "center" },
],
[
// JobDescriotiob is a string variable that contains \n character
{ text: JobDescription, style: "center" },
{ text: Price, style: "center" },
],
],
},
结果是
但是,当我直接在文本中使用 (\n) 时效果很好
table: {
headerRows: 1,
widths: ["80%", "20%"],
body: [
[
{ text: "Job Description", style: "center" },
{ text: "Total", style: "center" },
],
[
{ text: "test\nfff", style: "center" },
{ text: Price, style: "center" },
],
],
},
结果是
有什么方法可以通过变量换行吗?
【问题讨论】:
标签: typescript ionic3 pdfmake