How to "print" on paper in PHP?

What do I mean, let's say I have content:

"Stackoverflow is the best, bla bla bla ..."

I want to print the contents on paper, not on a computer monitor, how do I do this?

I saw a lot of CMS using php, had a print icon and could print it? (Well, I do not create CMS, just wondering how printing works in php)

+3
source share
5 answers

These CMS probably just call the window.print JavaScript method to open the print dialog:

 <span onclick="window.print()" class="pseudo-link">print this document</span> 

The rest is then processed by the browser and the operating system.

+7
source

The best way to do this is:

 <a href="#" onclick="window.print(); return false;">Print Me</a> 

Adding a return value of false; to the onclick event, the browser will stop by the link and using the <a> tag using href will cause the link cursor to appear when you hover over the mouse. Without it, there will only be an arrow cursor, which does not always make it an obvious reference.

+5
source

Printing on a client browser cannot be done using php. It was executed by javascript.

 <form> <input type="button" value="Print This Page" onClick="window.print()" /> </form> 

It is best to describe css printing for the page.

+3
source

Do you mean printing from a web server or client? If from the client.print () window in JavaScript, the http://www.javascriptkit.com/howto/newtech2.shtml trick will be executed.

I ask because I saw web systems that actually print from the server!

+2
source

Use javascript for this

 window.print(); 

window.print () : opens the Print dialog box for printing the current document.

+1
source

Source: https://habr.com/ru/post/1347621/


All Articles