siric Posted September 18, 2020 Share Posted September 18, 2020 I am trying to print an image to a thermal POS printer from a PHP script. I have managed to get a text file to print by saving it to a file and copying to the USB port and that works fine. Am running PHP on Windows. Would appreciate any assistance. Thanks Steve Quote Link to comment https://forums.phpfreaks.com/topic/311502-print-image-to-receipt-printer-from-php-on-windows/ Share on other sites More sharing options...
requinix Posted September 18, 2020 Share Posted September 18, 2020 38 minutes ago, siric said: I have managed to get a text file to print by saving it to a file and copying to the USB port and that works fine. How does that work, exactly? Does the USB show up as a file device you can just copy files to? What does that process require you to do? Quote Link to comment https://forums.phpfreaks.com/topic/311502-print-image-to-receipt-printer-from-php-on-windows/#findComment-1581479 Share on other sites More sharing options...
siric Posted September 18, 2020 Author Share Posted September 18, 2020 You create a port in Windows which is mapped to the USB port - in my case named Terow. You then create your text file and copy it to the port. $file = "print.txt"; $handle = fopen($file, 'w'); $linefeed = chr(10); $Data = "This is a test\n"; $Data .= "\n"; $Data .= "Line 1"; $Data .= "\n"; $Data .= "Line 2"; $Data .= $linefeed; $Data .= $linefeed; fwrite($handle, $Data); fclose($handle); copy($file, "//localhost/terow"); If I do the same with an image, as expected it prints junk. Can't find information on how to convert the image file to data that will be accepted by the printer. Quote Link to comment https://forums.phpfreaks.com/topic/311502-print-image-to-receipt-printer-from-php-on-windows/#findComment-1581481 Share on other sites More sharing options...
requinix Posted September 19, 2020 Share Posted September 19, 2020 4 hours ago, siric said: Can't find information on how to convert the image file to data that will be accepted by the printer. You'll have to do that. Educated guess says the image has to be a monochrome (B&W) bitmap. Quote Link to comment https://forums.phpfreaks.com/topic/311502-print-image-to-receipt-printer-from-php-on-windows/#findComment-1581485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.