Pdfmake: Prevent small table to be split

Created on 29 Oct 2018  路  2Comments  路  Source: bpampuch/pdfmake

Is there a way to prevent a table from being split around a page break?

For example, in the document definition below:

var dd = {
  content: [
    {
      table: {
        body: [
          [ { fillColor: '#DCE2EA', text: 'H' } ],
          [ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],
          [ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],
          [ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],
          [ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],[ '1' ],
        ],
        widths: [ 100 ]
      }
    },
    {
      table: {
        headerRows: 1,
        body: [
          [ { fillColor: '#DCE2EA', noWrap: true, text: '' } ],
          [ '1' ],['2']
        ],
        widths: [ 100 ]
      }
    }
  ],
}

I'd like the second table to be displayed on the next page automatically. My real life scenario is that I generate a lot of small tables and don't want them to be split. If I generate a large table that doesn't fit on a page, yes of course I'd like to split it, but not for small tables that fits onto a page.

Can I achieve this?
Thanks!

Most helpful comment

You can set table property: unbreakable: true.

All 2 comments

You can set table property: unbreakable: true.

@liborm85 Can you please give me a hint of where I can find this property in the documentation?

I see now that unbreakable can be used in any block, not only tables. The same has happened with some other properties that I could only find in forums or issues like this one.

Are some properties missing from the official documentation? https://pdfmake.github.io/docs/0.1/ Or am I just a lame docs reader? xD

Thanks in advance

Was this page helpful?
0 / 5 - 0 ratings