Help printing to a Zebra label printer from Tcl or C please

  • Thread starter Thread starter berkeman
  • Start date Start date
  • Tags Tags
    Printing
Click For Summary
SUMMARY

This discussion focuses on successfully printing to a Zebra label printer using Tcl/Tk and C programming. The user initially attempted to use Zebra Setup Utilities and various command-line methods but faced issues with extra data being sent to the printer. The solution involved sharing the printer on a Windows 7 system and associating it with a virtual LPT1 port, allowing the user to send ZPL files directly using the command copy /B checks1.zpl LPT1. This method effectively resolved the printing issues encountered.

PREREQUISITES
  • Understanding of Zebra Programming Language (ZPL)
  • Familiarity with Tcl/Tk scripting
  • Basic knowledge of Windows printer sharing settings
  • Experience with command-line operations in Windows
NEXT STEPS
  • Research Zebra Programming Language (ZPL) commands for advanced printing options
  • Learn about Tcl/Tk channel operations for direct device communication
  • Explore Windows printer sharing configurations for networked devices
  • Investigate creating C applications that interface with Tcl for enhanced functionality
USEFUL FOR

Developers working with label printing solutions, Tcl/Tk programmers, and IT professionals managing printer configurations in Windows environments.

berkeman
Admin
Messages
69,306
Reaction score
24,529
TL;DR
I need to print high-resolution graphics agency approval labels and MAC ID labels for a new product's Manufacturing Test Fixture that I'm helping with. My main program and test GUI are in Tcl/Tk, and I have helper programs in C. I'm having trouble understanding the best way to send files to the Zebra printer (ZPL files).
I'm able to send these ZPL files to my 600dpi industrial Zebra printer using their Zebra Setup Utilities program, but I'm not understanding yet how to send the files to the label printer from my Tcl/Tk Mfg test program.

With Google searches, I've found the ezprint option:

http://compgroups.net/comp.lang.tcl/printing-to-a-zebra-label-printer/1858009

but it is too old and it corrupts my Tcl installation and does not work. Ouch.

I've looked at this option recommended by my IT savant:

http://compgroups.net/comp.lang.tcl/printing-to-a-zebra-label-printer/1858009

but so far I'm not understanding the tserialport mechanics and linking it to my Tcl code...

I've tried making the Zebra label printer my Win7 default printer, and sending files via Notepad /P calls, but there are extra things sent with the ZPL file by Notepad or Notepad++ to the printer that seem to confuse it.

I'm thinking that I need to open a Tcl channel to the USB printer with the right syntax, but so far I haven't been able to figure that out. I'm fine with making a C helper app that I call from my Tcl program if that is an easier way to send text files to a printer with no extra information sent along.

Thanks for any ideas!

This is info on a lower-resolution Zebra printer that I'm using for some prototyping:

1590106635663.png
 
Last edited:
Technology news on Phys.org
jedishrfu said:
Is there a command that you can use ie not a GUI command ?
Yeah, that's what I was trying to find, so I could call it with the "exec" command from Tcl/Tk. I'd looked at DOS "print..." and "notepad..." commands from the command line, but each had issues with trying to get to a USB device.

Then *finally* after many Google searches, I ended up following a promising rabbit hole of combined search terms, and found a way using "Printer Sharing" to associate one of the old standard printer device names (LPT1) with the USB printer's optional shared resource name.

Here is a link to the page that did it for me ("Solution #2"):

https://www.codeproject.com/Questions/465476/copy-file-to-LP1-printer-using-commandline-in-wind

1590533076502.png

So here is what I did on my Mfg Test laptop (\\loanerx220) to finally be able use "copy" to sent the ZPL files (in /B binary format) to one of my Zebra label printers:

Open the Printers folder and set the desired Zebra printer as the default, then open its status window:

1590533185989.png


Click Printer, Properties, Sharing, “Share this printer” and name automatically gets filled in: ZDesigner 110XiIII Plus 300DPI

but change spaces to “_” to make the contiguous name: ZDesigner_110XiIII_Plus_300DPI

1590533209955.png


Associate LPT1 with that shared printer name…

In a Command Prompt DOS Box:

net use lpt1: \\loanerx220\ZDesigner_110XiIII_Plus_300DPI /persistent:yes

Then to copy a text (or ZPL) file to the USB printer in the shared name, use this (/B means send as binary):

copy /B checks1.zpl LPT1

Where "checks1.zpl" is a small checkerboard pattern file

:smile: And that worked finally! Whew! :smile:
 
Last edited:
We have many threads on AI, which are mostly AI/LLM, e.g,. ChatGPT, Claude, etc. It is important to draw a distinction between AI/LLM and AI/ML/DL, where ML - Machine Learning and DL = Deep Learning. AI is a broad technology; the AI/ML/DL is being developed to handle large data sets, and even seemingly disparate datasets to rapidly evaluated the data and determine the quantitative relationships in order to understand what those relationships (about the variaboles) mean. At the Harvard &...

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
6K
Replies
2
Views
6K
  • · Replies 13 ·
Replies
13
Views
4K