pdfjs icon indicating copy to clipboard operation
pdfjs copied to clipboard

Page Breaks across table rows prevent headers from appearing

Open KindaOK opened this issue 1 year ago • 2 comments

When a row has a page break within it, the current behavior is that table headers are not inserted. If there are other rows, however, then having no table headers seems incorrect. Sample output here: header-split.result.pdf (code as a unit test below). Is this the expected behavior? It doesn't seem right in the sample output. Existing unit tests also don't have any great examples of this because the only ones with rows across page breaks don't have any following rows.

module.exports = function(doc, { lorem })  {
  const table = doc.table({
    widths: [200, 200],
    borderWidth: 1,
  })

  const header = table.header()
  header.cell('Header Left', { textAlign: 'center', padding: 30, paddingTop: 100 })
  header.cell('Header Right', { textAlign: 'center', padding: 30, paddingTop: 100})

  const row1 = table.row()

  row1.cell(lorem.long, { fontSize: 11, padding: 10, backgroundColor: 0xdddddd })
  row1.cell('Cell 2', { fontSize: 11, padding: 10, backgroundColor: 0xeeeeee })


  const row2 = table.row()

  row2.cell(lorem.long, { fontSize: 16, padding: 10, backgroundColor: 0xdddddd })
  row2.cell('Cell 2', { fontSize: 11, padding: 10, backgroundColor: 0xeeeeee })

  const row3 = table.row()

  row3.cell('Cell 1', { fontSize: 16, padding: 10, backgroundColor: 0xdddddd })
  row3.cell(lorem.short, { fontSize: 11, padding: 10, backgroundColor: 0xeeeeee })

  doc.text('Foo')
}

KindaOK avatar Nov 24 '22 00:11 KindaOK