New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows 7 USB print support question #9

Closed
RushNetMx opened this Issue Mar 28, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@RushNetMx
Copy link

RushNetMx commented Mar 28, 2015

Hello, i´m new in php and I need print a ticket in a esc/pos thermal printer. Actually is connected in usb in Windows 7, can you help or guide me how can i do this using escpos-php, and also I need open a cash box. Thanks, any help is appreciated.

@mike42

This comment has been minimized.

Copy link
Owner

mike42 commented Mar 30, 2015

Hi RushNetMx,

USB/Windows as a combination is marked "not tested", as I haven't figured out a way to get a direct file pointer to the printer. This means that you are not really in beginner territory! I'll offer some tips, with the disclaimer that I've never used escpos-php under this setup.

The go-to setup appears to involve installing the printer as a text-only device, then sending it pre-made text files:

  • Add the printer as a Generic / Text only printer (on my computer, receipt printers add a "Virtual USB" printer port when connected, USB001). Share the printer so that it has an address like //machine/printer.
  • From PHP, make a tmpfile(), fopen() it and run the driver.
  • copy() the result to //machine/printer before deleting the text file.

And the alternative would be to send data using the port name. I'm not sure whether you need the printer "installed" with the text only driver to get this working:

  • From PHP, make a tmpfile(), fopen() it and run the driver. fclose() when done.

  • Print the file, then delete it. It

    $printer = "USB001";
    $file = (tmp file path)
    system("print /d:$printer: $file");
    unlink($file);
    

The third and slightly clunkier alternative is leverage the fact that Windows/Ethernet and Linux/USB are both known to work, and to to slip in a Raspberry Pi, using something like netcat as an intermediary to make your printer available from Windows over the network.

I have a windows VM, so no guarantees, but if I can get one of these working in the coming days, I'll be sure to wrap it into an actual working example.

@mike42 mike42 added the question label Mar 30, 2015

@mike42 mike42 changed the title Question Windows 7 USB print support question Apr 6, 2015

@mike42

This comment has been minimized.

Copy link
Owner

mike42 commented Apr 8, 2015

Hello again,

I've been working on some improvements in this space, and can confirm that I've had a USB printer working on Windows 7. I've posted more extensive details at question #14 (Print from a USB connected printer under Windows)

Best of luck,

@mike42 mike42 closed this Apr 8, 2015

@RushNetMx

This comment has been minimized.

Copy link

RushNetMx commented Apr 9, 2015

Hi! Thanks for your help, I'm going to do some tests, i'm beginner programming for php, so i hope make it. Many thanks for everything. Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment