vozzek Posted August 27, 2008 Share Posted August 27, 2008 Hi all, I've got a php script that builds a nice (html formatted) $message variable and sends it to the customer via email. This is basically an invoice. What I'd like is to send that exact invoice to my local printer. Nothing fancy, I just want to shoot that variable to my printer. I've tried the following: $handle = printer_open(); printer_set_option($handle, printer_MODE, "raw"); printer_write($handle, $message); printer_close($handle); It doesn't print, instead I get: Fatal error: Call to undefined function printer_open() I thought maybe I needed to name the printer, so I replaced the first line with: $handle = printer_open("HP LaserJet 3050 Series PCL 6"); Still no dice. I was reading somewhere that I might need to install a .dll file or change my php.ini? I'm not sure how to do this. Is there a simple way to do what I'm looking for? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/ Share on other sites More sharing options...
discomatt Posted August 27, 2008 Share Posted August 27, 2008 http://php.net/manual/en/printer.installation.php Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627040 Share on other sites More sharing options...
vozzek Posted August 27, 2008 Author Share Posted August 27, 2008 Okay, thanks. How do I access my php.ini file, and is it possible to do this if my site is being hosted by HostGator? Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627045 Share on other sites More sharing options...
kenrbnsn Posted August 27, 2008 Share Posted August 27, 2008 The printer functions only work on Windows servers. They do not print to your local printer, but to printers attached to the server. Ken Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627061 Share on other sites More sharing options...
DarkWater Posted August 27, 2008 Share Posted August 27, 2008 Or just: `lpr '$filename'` Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627067 Share on other sites More sharing options...
DyslexicDog Posted August 27, 2008 Share Posted August 27, 2008 You could just email a copy to yourself and print if necessary. Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627071 Share on other sites More sharing options...
vozzek Posted August 27, 2008 Author Share Posted August 27, 2008 You could just email a copy to yourself and print if necessary. A good idea, and this is what I'm doing now. I just kinda thought this would be a lot simpler than it is. Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627075 Share on other sites More sharing options...
DarkWater Posted August 27, 2008 Share Posted August 27, 2008 Are you on Windows or Linux? Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627110 Share on other sites More sharing options...
vozzek Posted August 27, 2008 Author Share Posted August 27, 2008 I'm working on Windows XP. Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627113 Share on other sites More sharing options...
DarkWater Posted August 27, 2008 Share Posted August 27, 2008 I'm working on Windows XP. Never mind then. <subliminal>P.S: Switch to Linux</subliminal> Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627116 Share on other sites More sharing options...
discomatt Posted August 27, 2008 Share Posted August 27, 2008 You can use javascript to bring up the print dialog. Simply output the 'pretty email' content to the browser, and call the javascript function. Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627128 Share on other sites More sharing options...
vozzek Posted August 27, 2008 Author Share Posted August 27, 2008 Can't talk right now... gotta go get Linux... Link to comment https://forums.phpfreaks.com/topic/121576-need-help-sending-a-variable-to-printer/#findComment-627132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.