3

I have a (cheap Chinese) thermal printer with USB connection with Windows and Linux drivers. I tested installing the Linux driver PPD with Gutenprint and usbtb at first without any luck.

So I would like to be able to send text-only direct to the printer. I can't see any virtual device under /dev/ that seems to correspond to the printer.

The output from System Information looks like this:

Generic Bulk Device:

  Product ID:   0x5011
  Vendor ID:    0x0416  (Winbond Electronics Corp.)
  Version:   3.00
  Serial Number:    1234567890
  Speed:    Up to 12 Mb/sec
  Manufacturer: Generic
  Location ID:  0x14100000 / 1
  Current Available (mA):   500
  Current Required (mA):    100
  1284 Device ID:   print00

Is there a way to send text (ASCII) to the printer?

When Mac OS X tries to identify the printer it manages to send PostScript code that the printer outputs verbatim so at least some parts of the communication with printer works. If I just could avoid sending PostScript code and instead just send ordinary text.

Receipt with printed PostScript code

3
  • Do you use Terminal ?
    – Ruskes
    Jun 13 '13 at 17:22
  • @Buscar웃 Well, I use iTerm2 but one problem is that lp doesn't give me raw access to the printer or usbtb but just uses the existing printer drivers. I guess a text-only printer driver would suffice for my needs but I haven't found one.
    – moonhouse
    Jun 17 '13 at 8:42
  • 1
    If you can't setup a printer through the usual Finder interface, you can try to access the CUPS web interface at: http://localhost:631/
    – mouviciel
    Jun 17 '13 at 13:43
6

I managed to install a raw printer driver and print to it from the command line.

Using CUPS/Gutenprint's web interface at http://localhost:631/ I added a printer with device URI

usbtb://Generic%00%00%06/Generic%20Bulk%20Device?serial=1234567890

and selected "Raw" as the make for the printer. (Please note that the serial URI parameter corresponds to the serial number for the USB device as listed in the question!)

I can now see the printer listed when issuing the command lpstat -p -d

printer Generic_usbtb is idle. enabled since Tue Jul 16 23:04:11 2013

To print the text file text.txt I write lp -d Generic_usbtb test.txt

2
  • 1
    This worked for me! You can find usbtb here (Gutenprint isn't required, just usbtb): sourceforge.net/projects/gimp-print/files - incredibly, it works on OS X Yosemite, despite usbtb's last release being from 7 years ago.
    – Andrea
    May 18 '15 at 21:27
  • Don't forget to run $ cupsctl WebInterface=yes first, to turn on the CUPS web interface Jan 10 at 12:10
2

Theory

We are talking about a line printer. This type of printer accepts raw text and prints it. They typically support 255 characters and must be configured to on of a few supported character sets, such as ASCII or CP437.

These printers accept "raw" input - meaning characters, spaces, line breaks, etc. They sometimes support images also.

Basically you'll need to

  1. Add a raw printer through CUPS (common unix printing interface)
  2. Send raw text, PDF, or PS to the printer

Steps

1) Turn on CUPS web administration

  1. Open a Terminal
  2. Enter the command $ sudo cupsctl WebInterface=yes

That will enable a feature that lets you add and remove printers from the CUPS localhost web administration site.

2) Find printer address

If it's a local printer:

  1. Run the command $ lpinfo -v | grep usb

You'll get a response that looks like:

direct usb:///80Series%20Receipt%20Printer%20200DPI?location=14200000

The usb:///<printer name>?location=<locationID> is your printer address on the USB hub. Copy that text.

If it's a network printer You'll want the IP address and port of that printer. The full address will be:

socket://<ip address>:<port>

For example:

socket://192.168.1.12:9100

3) Add printer

  1. Go to your CUPS Administration Page (http://localhost:631)

  2. Click Administration

  3. Click Add printer

  4. Click AppSocket/HP JetDirect (Don't click your existing printer if it shows up), click Continue

  5. Paste your printer address from Step 2 in the Connection input, click Continue

  6. Give the printer a name and description, click Continue

  7. Select Raw in the Make selection and click Continue. If you are super lucky you might see your manufacturer here. Good luck.

  8. Select Raw Queue (en) in the Model selection and click Add Printer

  9. Select printer options. For Raw Queue (en), you'll see a Starting Banner and Ending Banner. You'll probably want to select None for both of those.

4) Connect new printer to MacOS System Preferences

  1. Click Administration
  2. Click Add class
  3. Fill out the form. The Name field will be the human-readable name you want to appear in the Printers and Scanners section of System Preferences.
  4. Select the printer you just added from Members and click Add class
  5. Your printer should now appear in your Printers and Scanners
  6. (optional) - turn off CUPS web administration by issuing the command $ sudo sudo cupsctl WebInterface=no in your Terminal

5) Find your printer

  1. In your Terminal, issue the command $ lpstat -p. This will list your printers
printer HP_LaserJet_200_color_M251nw__0200B9_ is idle.  enabled since Tue Jan 15 00:24:06 2019
printer PDF_Printer is idle.  enabled since Sat Jan 11 14:00:23 2020
printer rongta is idle.  enabled since Sun Jan 10 14:37:44 2021
printer Rongta_80mm_Thermal_Printer is idle.  enabled since Sun Jan 10 14:42:19 2021

In my case I have a Rongta_80mm_Thermal_Printer

6) Print

Ok so here your mileage may vary.

  1. From your Terminal, issue the command $ lp -d <printer_name> file.txt to print file.txt to printer <printer_name>, and you'll get a print job ID in response.

In my case, I issued:

$ echo "hello" > file.txt
$ lp -d Rongta_80mm_Thermal_Printer file.txt
request id is rongta-61 (1 file(s))

Apparently you can print PDF and PostScript files this way as well, since MacOS's printing system is supposed to manage the translation between the system and the printer.

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .