Reputation:
What I mean is, lets say I have a content:
"Stackoverflow is the best, bla bla bla..."
I want to print the content in a paper, not computer monitor, how to do that?
I saw a lot of CMS using php, have a print icon, and able to print it? (Well, I am not creating a CMS, just wondering how the printing works in php)
Upvotes: 3
Views: 13719
Reputation: 3756
A better way to do it is like this:
<a href="#" onclick="window.print(); return false;">Print Me</a>
Adding the return false; to the onclick event will stop the browser following the link, and using the <a> tag with the href will cause the link cursor to appear on mouseover. Without it there would just be an arrow cursor which doesn't always make it obvious it's a link.
Upvotes: 5
Reputation: 655765
Those CMS are probably just calling the JavaScript method window.print
to pop up the print dialog:
<span onclick="window.print()" class="pseudo-link">print this document</span>
The rest is then handled by the browser and operating system.
Upvotes: 7
Reputation: 1587
Printing on a client browser cannot be done by php. Its done by javascript.
<form>
<input type="button" value="Print This Page" onClick="window.print()" />
</form>
Its best to describe a print css for the page.
Upvotes: 3
Reputation: 187110
Use javascript for this
window.print();
window.print(): Opens the Print Dialog to print the current document.
Upvotes: 1
Reputation: 29157
Do you mean printing from the Web server or from the client? If from the client window.print() in JavaScript will do the trick- http://www.javascriptkit.com/howto/newtech2.shtml.
I ask because I have seen Web based systems that actually do the printing from the server!
Upvotes: 3