waa1990
waa1990

Reputation: 2413

How can I set a page break dynamically depending on size of tables?

I am printing many dynamically generated tables whose sizes will vary, and I would like to find a way to set a page break before a table if it will not entirely fit on the page. How could this be done?

Upvotes: 0

Views: 1016

Answers (2)

ryankeairns
ryankeairns

Reputation: 808

You could use a page-break-before on all tables in combination with <thead>. Then it would start each new table on its own page and any that run over one page would get a repeating header on subsequent pages (i.e. the thead).

Upvotes: 0

Šime Vidas
Šime Vidas

Reputation: 185933

Try

table {
    page-break-inside: avoid; 
}

Upvotes: 1

Related Questions