Reputation: 1167
I know you can write files using PHP, but I was wondering if it was possible to print these files directly to a printer, on a Windows machine. Are there any pre-built functions to do this?
EDIT: I'm on localhost by the way
Upvotes: 1
Views: 3197
Reputation: 1
here is my worked solution
install an old version of xampp that contain php_printer.dll file for my case i install xampp-win32-1.6.8-installer.exe
enable the extintion from php.ini in php foldar and apache foldar
run this code
$printer_name = "80mm Series Printer";
$handle = printer_open($printer_name);
printer_start_doc($handle, "test_print.php");
printer_start_page($handle);
$font = printer_create_font("Arial", 100, 100, 400, false, false, false, 0);
printer_select_font($handle, $font);
printer_draw_text($handle, 'This sentence should be printed.', 100, 400);
printer_delete_font($font);
printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);
?>
Upvotes: 0
Reputation: 82028
If you are asking about whether it is possible to print from the server to a machine the server happens to connect to, then the answer is, Yes. (With CUPS it is possible to get this working with Linux/Mac).
If you're trying to get something to print on a user's printer, you will need to use JavaScript
Upvotes: 3
Reputation: 5799
Yes, it is - but only under windows: http://php.net/manual/en/book.printer.php
Upvotes: 1
Reputation: 24818
Maybe in the future with newer technologies like Google Cloud Print. For now you will have to print client sided unless the printer is connected to your server directly.
Upvotes: 1
Reputation: 31078
If the printer is attached to the machine the php process is running on (or available via the network and setup in windows), you can use PHP's COM functions to print.
Upvotes: 2