Log in

View Full Version : "print this page" ?



soscopyrights
01-31-2007, 11:44 AM
... I've done some reasearch and I came out with nothing... I need to know how to build a script, also known as 'PRINT THIS PAGE' script...
I really have no idea on how to start...
Can any1 point me in the right direction?

djr33
01-31-2007, 11:59 AM
That totally depends on what you want, and has very little to do with PHP.

Basically, just link to a printer friendly copy of the page. If you want to go through all the effort, this page could, in fact, be PHP generated, I suppose.

Aside from that, there are some ways to try to make the printer print by javascript command and other ways of assigning a different 'printing' document. Look on the DD scripts library for both... I think.

soscopyrights
01-31-2007, 12:14 PM
from what you're saying...if there is a easier way...I'll chose what you call 'printer friendly copy'...there are php functions that help me to somehow 'clear' the junks from the original web address, or I just...have to build it?

thetestingsite
01-31-2007, 03:22 PM
Basically, you would have to build the page with no advertisements, extra little images/items that would cause a printer to use a lot of ink, and other items that people just don't want to print. As far as php functions go, I don't know of any pre-defined functions that would clear all the junk from the original page. You could probably make something using preg_replace or some other items like that.

Hope this helps.

shachi
01-31-2007, 06:25 PM
I'd actually suggest you to use css, that'd make it a lot easier. You could use display: none;

djr33
01-31-2007, 10:40 PM
That may be helpful.

the only wayt that PHP would help in actually generating the page would be a complex html-parsing script. This is something that would be a challenge to some (if not all) of the best coders here... not just a quick fix. It's certainly possible and easy to theorize... just hard in practice. Mainly, you'd have to program the PHP to know when something should/should not be shown, and how!

soscopyrights
02-01-2007, 07:09 AM
ok guys. I managed to a print-friendly page, somehow generated by php, it's actually easy... no images...just the news...
I've used


<body onload='window.print()'>

also


<span onclick='javascript:window.print();' class='detaliilnk'>Re-print</span>

...I got it... thanks guys...

thetestingsite
02-02-2007, 05:08 AM
Glad to hear it's working for you; and also, thanks for posting your solution. I'm sure it may come in handy for other users to these forums.