【发布时间】:2016-09-12 16:30:16
【问题描述】:
如何在 PDFmake 中使用嵌套/子表?我试过简单地放入多个表格,但这不会自动重复顶级表格的标题以进行分页。
【问题讨论】:
标签: pdfmake
如何在 PDFmake 中使用嵌套/子表?我试过简单地放入多个表格,但这不会自动重复顶级表格的标题以进行分页。
【问题讨论】:
标签: pdfmake
此代码是使用子表的简化示例。它改编自 pdfmake 游乐场的表格部分(通过 Google 搜索不容易找到)。
将以下内容粘贴到:http://pdfmake.org/playground.html
// playground requires you to assign document definition to a variable called dd
var dd = {
content: [
{ text: 'A simple table with nested elements', style: 'subheader' },
'It is of course possible to nest any other type of nodes available in pdfmake inside table cells',
{
style: 'tableExample',
table: {
headerRows: 1,
body: [
['Column 1', 'Column 2'],
[
{
stack: [
'Let\'s try an unordered list',
{
ul: [
'item 1',
'item 2'
]
}
]
},
[
'or a nested table',
{
table: {
body: [
[ 'Col1', 'Col2', 'Col3'],
[ '1', '2', '3'],
[ '1', '2', '3']
]
},
}
]
]
]
}
},
]
}
【讨论】:
我需要实现与上面几乎相似的功能。我已经尝试了很多,但没有做对。如何创建一个使用 pdfmake 生成 pdf 输出的 json 数组?我需要在一个表中创建一个表:
var dd = {
content: [
{
text: 'A simple table with nested elements',
style: 'subheader'
},
'It is of course possible to nest any other type of nodes available in pdfmake inside table cells',
{
style: 'tableExample',
table: {
headerRows: 1,
body: [
['Column 1', 'Column 2'],
[
[
'or a nested table',
{
table: {
body: [
[ 'Col1', 'Col2', 'Col3'],
[ '1', '2', '3'],
[ '1', '2', '3']
]
},
}
]
]
]
}
},
]
}
【讨论】: