how to print the current html page from php

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
eidos
Forum Newbie
Posts: 1
Joined: Wed Nov 03, 2010 1:19 pm

how to print the current html page from php

Post by eidos »

Hi All,

I'm using the following code to print the current html page to my local printer

ob_start();
$content = ob_get_contents();
$handle = printer_open("HP Deskjet F2400 series");
printer_write($handle, $content);
printer_close($handle);


the printer is working and print the html file (not the rendered page)
how can I render the page and send it to the printer?

when I add: printer_set_option($handle, PRINTER_MODE, "raw"); the printer is not responding, I'm using php version 5.3.0


thanks in advance,
Eido
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: how to print the current html page from php

Post by cpetercarter »

I don't think you can do what you want using php. php can take the process only as far as producing the html of the web page. The page is actually rendered by a browser. Without a browser, you cannot see a rendered web page, and you similarly cannot print one.
User avatar
awebtech
Forum Newbie
Posts: 21
Joined: Sun Nov 07, 2010 4:54 pm
Location: Russian Federation

Re: how to print the current html page from php

Post by awebtech »

eidos,

The output buffer (which is turned on by ob_start()) does not suppose to contain the rendered page, it actually stores the output, which is "echoed" by the script. Which is HTML in most cases.

So, could you specify for what purpose you need to get the rendered page in PHP ?

Actually, it is much easier to print the rendered page using JavaScript.
Post Reply