Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Do not split table across multiple pages #2196

Unanswered
austriancoder asked this question in Q&A
Discussion options

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?

You must be logged in to vote

Replies: 1 comment 3 replies

Comment options

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?

You must be logged in to vote
3 replies
Comment options

Good question - I think I switched to an other framework.

Comment options

nice... lol. no worries then, thanks for getting back to me though. 👍🏼

Comment options

FWIW, I just tried something random and managed to resolve this...

every instance of Paragraph needs the option keepNext to be set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /