Third row as table header in pdfMAke pdf creator engine

1.9k Views Asked by At

I just went through this playground of pdfMake pdf creator engine and it nicely explains how to print a table using pdfMAke as,

table: {
        headerRows: 1,
        body: [
                [{ text: 'Header 1', style: 'tableHeader' }, { text: 'Header 2', style: 'tableHeader'}, { text: 'Header 3', style: 'tableHeader' }],
                [ 'Sample value 1', 'Sample value 2', 'Sample value 3' ],
                [ 'Sample value 1', 'Sample value 2', 'Sample value 3' ],
                [ 'Sample value 1', 'Sample value 2', 'Sample value 3' ],
                [ 'Sample value 1', 'Sample value 2', 'Sample value 3' ],
                [ 'Sample value 1', 'Sample value 2', 'Sample value 3' ],
                                ]
        },

where headerRows: 1 will consider the first row as table header. Is there any ways to consider the third row as header using this engine so that the third row will repeat as header in the next consecutive pages of pdf document.

Also is it possible to draw borders around columns which drawn below.

        columns: [
            { text: 'First Column goes here.'},
            { text: 'Second column goes here.'},
            { text: 'Third column goes here.' }
        ]
1

There are 1 best solutions below

0
On

late answer but unfortunately that's impossible, only the first row can be used as header.

As a workaround, I would suggest building tables by yourself, allowing you to repeat any line you want. It's more constraining tho, since you need to handle the overflows manually to insure the repetition of the table on each page.