-
-
Notifications
You must be signed in to change notification settings - Fork 566
Do not split table across multiple pages #2196
-
Hi.
I have a small problem and hope somebody can help me out.
private createEventsTable() : Table {
const rows: Array<TableRow> = [];
rows.push(this.createTableHeader('Cell 1', 'Cell 2', 'Cell 3'));
this.items.forEach((item) => {
const row = new TableRow({
children: [
new TableCell({
width: {
size: 2000,
type: WidthType.DXA,
},
children: [new Paragraph(item.cell1)],
}),
new TableCell({
width: {
size: 2000,
type: WidthType.DXA,
},
children: [new Paragraph(item.cell2)],
}),
new TableCell({
width: {
size: 2000,
type: WidthType.DXA,
},
children: [new Paragraph(item.cell3)],
}),
],
});
rows.push(row);
});
return new Table({
columnWidths: [2000, 2000, 2000],
rows
});
}
What properties do I need to set that this table gets not split into multiple pages?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 3 replies
-
I just found this package a few days back, and I'm struggling with this same point...
I'm generating multiple tables programmatically from my reference data, each of which only have 2 columns and 3 rows, with an empty paragraph as a "spacer" between each table, but often I find when a table starts near the bottom of a page then 1 or 2 of its rows will instead render at the top of the next page.
@austriancoder, did you ever manage to get around this?
Beta Was this translation helpful? Give feedback.
All reactions
-
Good question - I think I switched to an other framework.
Beta Was this translation helpful? Give feedback.
All reactions
-
😄 1
-
nice... lol. no worries then, thanks for getting back to me though. 👍🏼
Beta Was this translation helpful? Give feedback.
All reactions
-
FWIW, I just tried something random and managed to resolve this...
every instance of Paragraph needs the option keepNext to be set to true.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2