Print a web page so tables don't get cut off.

Posted on 2003-03-23
Medium Priority
Last Modified: 2010-04-06
I have a web page that displays a dynamic table.  The table is repeated based on the number of records returned by the querry.  This number could be different each time.  Each dynamic table will also have different heights.  I want to be able to print all the tables with out part of one being on the bottom of one page and the rest printing on the top of the other.  So, if 2 tables will fit completly on the first page but the third will not it will move that one to the next page.  That next page will then print as many tables it can on that page.  This could be 1, 2, or 5.  I have searched for javascript code and vbscript but have been unsuccessful.  Does anyone know how to do this? Is it even possible.
Question by:lyptus
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 14

Accepted Solution

avner earned 300 total points
ID: 8194040
Cannot be done, you can never know what wuld be the user's setting for the printer.

What you can do is :
1. Add <br style="page-break-after:always"/>
This will force a page break.
2. Generate a PDF which is the only 100% safest way for Web printing.

Expert Comment

ID: 8194661
See http://www.rustyparts.com/pdf.php

With example3 you can generate a pdf File from what is currently displayed in the browser.

Look also in the forum.

LVL 12

Expert Comment

by:Dean OBrien
ID: 8194963
Just a thought, could you not print out individual <div>'s, store each of you new tables in div1, div2, div3, etc then have some sort of function that checked at the number of records in each table, i.e. table 1 has 13 records, table 2 has 8 records and only 20 fit on a page, then you know to print each them separate.  (Not very clear i know!)


Expert Comment

ID: 8195824
(to easynow111)
As avner stated before: You never know the user's printer settings. So you cannot tell how many table rows will fit on one page.

Besides temporary PDFs have a lot of advantages:

- The user can save the displayed webpage without loosing pictures or links.
- There is a printing preview
- If the output does not fit on one page, the user can chose which pages to print
- The user can print parts of pages.



Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question