Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO GET A PRECISE PRINTING?

Status
Not open for further replies.

alexfusion

Programmer
Feb 5, 2001
94
AR
Hello Everyone,
I don't know if this is the proper forum to ask this question but I hope that it will be:
I have developed an intranet aplication in CF.
The employees need to print results from a database.
It was built the results page that lists several orders entered by the employees according to a search criteria.That's fine.
The problem is when they have to print these results.Due to the dynamic content,every result page will be different in length.So my question is how can I get that the printed results fit in the paper exactly,so they are perfectly readable? I mean the results not broken in half by the printer.Is it possible a printer friendly version of the results page?
How can I solve this problem?

Any help or suggestion welcome.

Thank you so much.

Alexfusion

mixale@hotmail.com
 
The problem is, you never know what margins your users will use, what make and model of printer, etc...

I assume your results are displayed in an HTML <TABLE> or perhaps <DIV> tags. You can assign an ID attribute to each <TR> and use onBeforePrint() to call a JavaScript function which counts the offsetHeight of each row. When it gets to a predetermined number (say 600px) insert &quot;page-break-before: always&quot; into the current row.

In layman's terms:
1. Assign an ID to each row...a counter works best. Call it row#CurrentRow# if you'd like.

2. use onBeforePrint to call a function...we'll call it measureRows()

3. The function needs to loop through the number of rows in the table. This number is just the RecordCount of your query (plus 1 if you have a header row)

4. Set a counter (we'll call it rowSize) equal to 0.

5. Now as you go through the loop, set rowSize equal to the offsetHeight of each row. Keep adding to rowSize and when rowSize exceeds 600px you can say &quot;row#CurrentRow#.style.pageBreakBefore='always';&quot; where #CurrentRow# is whatever iteration of the loop you're on.

6. Reset rowSize to 0 and press on until you're counted every row.

A little convoluted? I agree, but it works. Kevin
slanek@ssd.fsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top