printing template

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bazboy
Forum Newbie
Posts: 2
Joined: Fri Sep 08, 2006 8:10 am

printing template

Post 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!
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Post 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.
bazboy
Forum Newbie
Posts: 2
Joined: Fri Sep 08, 2006 8:10 am

Post 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
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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"
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply