Home:ALL Converter>Nested/Sub Tables with PDFMake

Nested/Sub Tables with PDFMake

Ask Time:2016-09-13T00:30:16         Author:Elijah Lofgren

Json Formatter

How do I use nested/sub tables with PDFmake? I've tried simply putting in multiple tables but that doesn't automatically repeat the top level table's header for page breaks.

Author:Elijah Lofgren,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/39454842/nested-sub-tables-with-pdfmake
Elijah Lofgren :

This code is a simplified example of using a sub-table. It is adapted from tables section of the pdfmake playground (wasn't easy to find via Google searching).\n\nPaste the following into: http://pdfmake.org/playground.html\n\n// playground requires you to assign document definition to a variable called dd\n\nvar dd = {\n content: [\n\n { text: 'A simple table with nested elements', style: 'subheader' },\n 'It is of course possible to nest any other type of nodes available in pdfmake inside table cells',\n {\n style: 'tableExample',\n table: {\n headerRows: 1,\n body: [\n ['Column 1', 'Column 2'],\n [\n {\n stack: [\n 'Let\\'s try an unordered list',\n {\n ul: [\n 'item 1',\n 'item 2'\n ]\n }\n ]\n },\n [\n 'or a nested table',\n {\n table: {\n body: [\n [ 'Col1', 'Col2', 'Col3'],\n [ '1', '2', '3'],\n [ '1', '2', '3']\n ]\n },\n }\n ]\n ]\n ]\n }\n },\n\n ]\n\n}\n",
2016-09-12T16:30:16
yy