bbulpett / zebra-zpl

Gem for using Ruby to print Zebra labels
MIT License
73 stars 32 forks source link

error on printing label #37

Closed adas172002 closed 5 years ago

adas172002 commented 5 years ago

While on macOS issuing #print on Zebra::PrintJob instance with one argument (like stated in documentation) is throwing wrong argument number error, #print is expecting 2 arguments. Quickly checking method's code revealed that ip of printers queue should be a second argument. However, #print with 2 arguments is also generating an error lp: No such file or directory, which in fact refers to code in private #method send_to_printer. Executing lp command without option -h #{@remote_ip} is sending temp file to the printer, executing with option -h #{@remote_ip} is returning error lp: No such file or directory. Is it just me or this private method #method send_to_printer needs a fix?

mtking2 commented 5 years ago

The docs are a bit out of date per issue #11. But you are correct, right now the #print on Zebra::PrintJob does take 2 arguments: the label to be printed and the ip/host of the printer queue.

The error lp: No such file or directory comes from the lp command. This usually means that either the ip/host cannot be reached, the name of the print queue does not exist at the specified host, or the file itself does not exist.

In your case, I think the issue is with the ip you are providing when calling #print. When the -h flag is omitted on the lp command I believe it defaults to localhost. So you would need to provide either localhost, 127.0.0.1, or 0.0.0.0 as the ip if your cups queues are on your local machine.

e.g.

print_job.print label, '127.0.0.1'

Both the #print and private #send_to_printer methods could probably use some work. Some ideas we have been throwing around are:

Keep an eye on #11 for those docs to be updated. We hope to tackle that soon.