Page 1 of 1

printing template

Posted: Fri Sep 08, 2006 8:30 am
by bazboy
hi
would appreciate any suggestions on the following project I'm working on:
I run a webiste for several users who enter data into mySQL tables. Reports are generated with php, which the users need to print.
The reports can span several pages.
Is it possible to ensure that certain info (eg report name, date, page number, legend etc) is printed on each page, regardless of how long the report is?

Here is an example:

REPORT 001
content of report
content of report
content of report
content of report
content of report
content of report
END OF REPORT 001

If I print this, say that appears like so (over two pages):

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
REPORT 001
content of report
content of report
content of report
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
content of report
content of report
content of report
END OF REPORT 001


I'm trying to ensure that all pages have the same header and other info, whilst the content is printed out:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
REPORT 001
content of report
content of report
content of report
PAGE 1 OF REPORT 001
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
REPORT 001
content of report
content of report
content of report
PAGE 2 OF REPORT 001
END OF REPORT 001

Any help is appreciated!

Posted: Fri Sep 08, 2006 9:10 am
by someberry
One way would be to count how many lines each page can hold. The whilst looping through the contents, see if it is the max line number. If it is, end the current content and add the footer, then continue by adding the footer and continuing to loop through the content.

However, it would depend upon the size the user (only you?) is printing the letters out at.

That is if I think I understood you correctly.

Posted: Fri Sep 08, 2006 9:21 am
by bazboy
Thanks for your comment -
Line counting is a good idea, but the users have different printer setups, so each user's max lines per page may vary.
I realise that this is more a HTML problem than PHP

Thanks anyway

Posted: Fri Sep 08, 2006 1:56 pm
by nickvd
Assuming that your users are using a decent browser (ff/opera), you can use css to control where the page breaks, and where it does not. try a google search for "css for print"

Posted: Fri Sep 08, 2006 2:09 pm
by feyd
For report generation I always use PDF. ezpdf for instance is quite helpful in this regard as you can set up a template in the code and it will automatically duplicate the template across pages.