Looking for a trick to provide pagination for printable HTML reports

liunx

Guest
Hi All,<br />
<br />
My application generates a report in HTML format,<br />
which is sent to a browser.<br />
<br />
Now my users want to print this report and here<br />
we have an issue of proper pagination:<br />
of course they want report headers to be printed<br />
at the top of every page etc.<br />
<br />
Is there any trick or workaround to achieve this ?<!--content-->unless you put teh headers in I don't think there is a work around to add a header to print when it prints. you have little contol over the browser when it comes to printing.<!--content-->I use a handy little trick of creating a excel file of the report, which seems to print very well and satisfy everyone. <br />
<br />
There isn't a default way to put headers on every page in case the printer breaks the page off. some people make a 'print only' html page with only the report stuff and nothing else. That is a step in the right direction-but wouldn't help out too much.<!--content-->Well HTML just does not print very well. If the printing is critical<br />
then you nee a more printer friendly format like PDF.<br />
<br />
The closest you will get to a workaround is IE only, and requires<br />
some management during report generation. The server side will need<br />
to count the lines and insert the header. The head of the page will<br />
need this style:<br />
<br />
<style><br />
.header {page-break-before:always; }<br />
</style><br />
<br />
Then the page header gets put in the report this way:<br />
<br />
<div class="header"><br />
the text of the header goes here<br />
</div><br />
<br />
That has to be inserted at each place where you need tha page<br />
break. Of course it will also show up in the displayed version<br />
and the local browser and printer setting can still screw it up<br />
big time, but HTML is optimized for display, not printing.<br />
<br />
Cd&<!--content-->This might help <!-- m --><a class="postlink" href="http://www.webreference.com/js/column92/">http://www.webreference.com/js/column92/</a><!-- m --> "Print Templates, Part III: HeaderFooter" Mind you, at a quick glance it looks like it's IE-only.<br />
<br />
Neil<!--content-->Adding to what the Cobolosaurus said, in IE5 you can use the @media rule:<br />
<br />
<style><br />
.header { position: relative;<br />
visibility: hidden;<br />
display: none }<br />
@media print { <br />
.header { page-break-before: always;<br />
position: relative;<br />
visibility: visible; <br />
display: inline } <br />
}<br />
</style><br />
<br />
<div class="header">Header Stuff</div><br />
<br />
This won't show up on screen (due to the first definition), but will on print (due to the second).<!--content-->
 
Back
Top