Page 1 of 1

how to print the current html page from php

Posted: Mon Nov 08, 2010 4:42 pm
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

Re: how to print the current html page from php

Posted: Tue Nov 09, 2010 1:15 am
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.

Re: how to print the current html page from php

Posted: Tue Nov 09, 2010 1:28 am
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.