Connecting Tech Pros Worldwide Forums | Help | Site Map

Printer Friendly page

weetat.yeo@gmail.com
Guest
 
Posts: n/a
#1: Aug 7 '06
Hi all ,

I have php page which the data in the page are extracted from MYSQL
database.
The data are retrieved when user click submit button .
In the php page , there is a print button for user to print the php
page.
Presently, i am using javascript window.print() which not an elegant
option.

I tried to use CSS for printer friendly in php page , however i did not
know how to start.
Anyone have any idea how to , please share it with me .

Thanks
- weetat


Erwin Moller
Guest
 
Posts: n/a
#2: Aug 7 '06

re: Printer Friendly page


weetat.yeo@gmail.com wrote:
Quote:
Hi all ,
>
I have php page which the data in the page are extracted from MYSQL
database.
The data are retrieved when user click submit button .
In the php page , there is a print button for user to print the php
page.
Presently, i am using javascript window.print() which not an elegant
option.
>
I tried to use CSS for printer friendly in php page , however i did not
know how to start.
Anyone have any idea how to , please share it with me .
>
Thanks
- weetat
Hi Weetat,

I always solve this the simple way:
1) Make a button: "Printer friendly page"
2) If somebody hits that button, simply create a popupwindow in which you
retrieve the data again, and display it with little/no colors, just black
and white.
From there you can call window.print() safely.

Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too, but I
prefer the first option because the user can see what will be printed
beforehand excactly.

just my 2 cent.

Regards,
Erwin Moller
Jesper H.
Guest
 
Posts: n/a
#3: Aug 8 '06

re: Printer Friendly page


On 2006-08-07, Erwin Moller wrote:
Quote:
Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too,
but I prefer the first option because the user can see what will be
printed beforehand excactly.
Doesn't most browsers nowadays have a print preview function that takes
the CSS into consideration? I'm pretty certain that Firefox did last
time I checked.

--
|\_/| ,(Meow) Jesper H. <xyborx+usenet@xyborx.dk>
(^.^)
`^' Sanity is an illusion
Chung Leong
Guest
 
Posts: n/a
#4: Aug 8 '06

re: Printer Friendly page


Jesper H. wrote:
Quote:
On 2006-08-07, Erwin Moller wrote:
Quote:
Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too,
but I prefer the first option because the user can see what will be
printed beforehand excactly.
>
Doesn't most browsers nowadays have a print preview function that takes
the CSS into consideration? I'm pretty certain that Firefox did last
time I checked.
>
--
|\_/| ,(Meow) Jesper H. <xyborx+usenet@xyborx.dk>
(^.^)
`^' Sanity is an illusion
Yeah, and I don't know how many times I've seen the previews of pages
that wouldn't print right :-)

I have to agree with Erwin. It's far easier to create a separate,
printable version of a page than having to come up with a stylesheet
that works for both screen and printer. And sometimes your printable
version will be structurally different from the screen version. For
on-screen viewing you might break a long article into multiple pages.
For printing you would want to output the whole thing.

Dikkie Dik
Guest
 
Posts: n/a
#5: Aug 8 '06

re: Printer Friendly page


Why don't you just use a @media print{} section in your CSS file?

Best regards

weetat.yeo@gmail.com wrote:
Quote:
Hi all ,
>
I have php page which the data in the page are extracted from MYSQL
database.
The data are retrieved when user click submit button .
In the php page , there is a print button for user to print the php
page.
Presently, i am using javascript window.print() which not an elegant
option.
>
I tried to use CSS for printer friendly in php page , however i did not
know how to start.
Anyone have any idea how to , please share it with me .
>
Thanks
- weetat
>
R. Rajesh Jeba Anbiah
Guest
 
Posts: n/a
#6: Aug 13 '06

re: Printer Friendly page


Erwin Moller wrote:
<snip>
Quote:
I always solve this the simple way:
1) Make a button: "Printer friendly page"
2) If somebody hits that button, simply create a popupwindow in which you
retrieve the data again, and display it with little/no colors, just black
and white.
From there you can call window.print() safely.
>
Alternatively, you can make a stylesheet for the printer, and tell the
browser to use that (without the popupwindow). That should work too, but I
prefer the first option because the user can see what will be printed
beforehand excactly.
<snip>

FWIW, my way:
1. print.css set to print media and other style and alternate styles
for screen
2. <a href="currentlink+?print=1" rel="nofollow"
class="print-link">Printer friendly page"</a>
* rel="nofollow" so that the crawlers won't crawl it (avoid multiple
crawl of same page)
3. Add popup window for the link by hooking "print-link" class using
Behaviour.js (now using modified better version of it and need to
document it)
4. The top global file sees if $_GET['print'] is set, if so, when it
renders styleseet related links, it sets print.css to screen and trims
other styles.

Advantages: Not much coding; easy to plug it to existing pages.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Closed Thread