Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print Stylesheets for pages with long horizontal tables

I have a page that spits out db data in long horizontal tables.

I need to print it nicely so it does not cut off. Any tips ?

like image 232
Boris Smirnov Avatar asked Nov 15 '08 14:11

Boris Smirnov


People also ask

How do you deal with page breaks when printing a large HTML table?

In order to prevent a table to be split in several pages it is required to apply the page-break-inside and page-break-after styles to all of its contents. This trick works unless the table occupies more space than a full page.

How do I display large tables in HTML?

tl;dr - To speed up loading a large HTML table on the client, start with the table CSS set to display: none; . Once the document is ready, set it back to display: table; . This reduced my client-side render time from 60 seconds to 6 seconds on a table with ~400,000 cells.

What is @media print?

Print media, as you know is one of them. Print media is one of the oldest and basic forms of mass communication. It includes newspapers, weeklies, magazines, monthlies and other forms of printed journals. A basic understanding of the print media is essential in the study of mass communication.

How do you print a table in HTML?

document. write('<html><head><title>Table Contents</title>'); //Print the Table CSS. var table_style = document.


1 Answers

  1. Change table into horizontal one with many rows (swap rows/columns)

  2. Suggest users to switch to Landscape mode. AFAIK there's no way to do that programmatically in current browsers (CSS3 defines @page {size:landscape})

  3. Split table every few columns (i.e. instead one with 100 columns, generate 10 tables with 10 columns each). Use CSS table {display: inline-table} to show them all side-by-side on screen. This trick works only if you don't have cells with varying heights.

like image 109
Kornel Avatar answered Oct 14 '22 08:10

Kornel