Vinee
Vinee

Reputation: 1654

use printer via php

I have four computers and one printer in Intranet and I installed WAMP on one of Windows machines. Now I want to execute PHP script, from window machine browser (or via Ajax etc) to print data. I need to know will it be possible? if yes then how?

Upvotes: 1

Views: 3850

Answers (1)

Mihai Iorga
Mihai Iorga

Reputation: 39724

Use printer functions:

<?php 
    $printer = "\\\\hostname\\printername"); 
    if($ph = printer_open($printer)) { 
       $fh = file_get_contents('myfile.txt');
       printer_set_option($ph, PRINTER_MODE, "RAW"); 
       printer_write($ph, $content); 
       printer_close($ph); 
    } else {
        echo "Can't connect to printer"; 
    }
?>

Upvotes: 1

Related Questions