With printer_open()
function in php, I am able to print the string that I saved in $content
variable, and able to print from a file.
$printer = "\\\\Pserver.php.net\\printername";
$handler = printer_open($printer);
$content = "Test Content"; //string
printer_write($handler, $content);
printer_close($handler);
But have a html output that I generated from the database, and is showing in the webpage, I need to print that directly to the printed in the same format once the page loads, I tried a lot but I dont know what I should do to make the printer to print directly the same HTML output once the page loads using the printer_open()
.
What should I do? Please suggest a better method than this if any
UPDATED
I dont want to use windows.print() method of javascript, since it shows the print dialogue box instead of initiating the printing job directly to the printer
I want users to hit submit form and printer to print the receipt directly without asking them anything
You can try to use output buffer:
ob_start();
// generate your output from the DB here
// .....
// Send generated output to the printer
printer_write($handler, ob_get_contents());
// And show it to client on the frontend
ob_end_flush();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With