Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stategies for printing multiple page HTML tables and dealing with page breaks

Tags:

html

css

printing

I have seen this similar question.

(I highlighted the important bits to make skim-reading the question faster)

To add to it though, I would like to format an HTML table (with a lot of rows) in such a way that when printed, it would repeat the table headers after each page break. Another words, for the table headers to be visible at the top of each printed page.

Some things I have tried was, when generating the HTML, counting the number of rows, then putting blank rows where I was expecting a page break to occur. At this point I would put in the table headers again.

However, depending on what printer is used, the page breaks end up in different spots. Because each printer seems to have slightly different margin settings, font sizes, etc...

This of course, throws off this whole idea of predicting where a page break will occur.

What strategies do other people use to print HTML tables/forms while maintaining proper formatting?

any ideas?

like image 835
7wp Avatar asked Sep 02 '10 17:09

7wp


1 Answers

Per your own link, posted David Thomas answers it:

On a tangent, it might be worth adding a to your table with the following css thead {display: table-header-group; } so as to print the table-header on all subsequent pages (useful for loooooong data tables). – David Thomas Nov 19 '09 at 14:38

Whats wrong with that solution? Does it not fit the bill?

About table-header-group:

table-header-group (In HTML: THEAD)

Like 'table-row-group', but for visual formatting, the row group is always displayed before all other rows and row groups and after any top captions. Print user agents may repeat header rows on each page spanned by a table. If a table contains multiple elements with 'display: table-header-group', only the first is rendered as a header; the others are treated as if they had 'display: table-row-group'.

like image 169
Jakub Avatar answered Nov 13 '22 21:11

Jakub