Printing a barcode trough ZPL code generated and sent by excel-vba - excel

I have read some people managed to print trough DOS and emulating a parallel port trough USB connection and sharing the printer.
The printer in this case is not atached via USB but via LAN cable.
this is the ZPL code I generated for the label:
CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR5,5~SD15^JUS^LRN^CI0^XZ
^XA
^MMT
^PW320
^LL0240
^LS0
^BY1,3,131^FT6,180^B3N,N,,N,N
^FD[Barcode_here]^FS
^PQ[quantity to print],0,1,Y^XZ
Where [Barcode_Here] will be the barcode taken from an Excel cell and [quantity to print] will also be the result of some Excel table calculations.
I have read that this needs to be sent to the printer in RAW format and I have read the printer can be set up with passtrough character. I know from the settings that i need to mark my ZPL code with ${ and }$
What I need help with is: how would I go about sending the two parts of the code I have given above to the printer using only Excel vba code so that my project can be self contained and need nothing else?
I need the two parts to be 2 different sends since the first part (from what i understand) is a "setup" code and it would significantly slow down the process if repeated.
Is it even at all possible? (I have seen some people cimenting with something of the sort gave up and wrote a parallel comunication emulation in c++ to solve this).
Thanks for the help, i am unsure if this is considered off topic, if it is so let me know where can i ask for assistence as a comment please.
EDIT: This is an example of people shifting from vba to c++ to solve this issue

Install your Zebra printer on your local Windows using the IP address of your Zebra, by creating a new tcp/ip port. Use the Generic / Text Only drivers.
Copy/paste your ZPL code to notepad, and print. The ZPL code will be interpreted by the Zebra and generate the corresponding label. There is no set up with passtrough character.
From your VBA you can create a txt file containing your ZPL code, and print it with notepad.

Related

Printing to Star TSP143LAN from NodeJS on Linux, with formatting

I have the proper CUPS drivers installed: I can print to my Star TSP143LAN using any application with print capability (like Chrome). I can print to this printer using the node-printer module, by specifying either the printer name or the printer’s network address, and setting the print mode to TEXT.
But I can’t seem to format what I print from NodeJS using the node-printer library. If I set the mode to RAW and send commands as specified in Star’s Command Line Emulator manual for this printer, node-printer will report a successful print but nothing happens. It doesn’t print.
I’m attempting to send these RAW commands because I want to do various formatting operations like make the font larger or bold, and so on.
I’ve tried the node-thermal-printer module but I’ve had no luck.
I’ve been scouring the internet for some help on this issue but I haven’t been able to find much. I’ve seen it mentioned that the TSP143 LAN doesn’t communicate in the same way as other star products and it’s best to use Star’s drivers as a go-between, but I’m not sure what that means. (I thought I might be doing that already when specifying the printer’s class name when attempting to print from node-printer...)
I didn’t have much trouble implementing the Star Swift SDK into an iOS app and doing formatting operations there. But I need to print from a NodeJS environment on Linux. I’m at a loss.
If there’s anybody to whom this sounds familiar and can point me in the right direction I’d be very grateful...
Thanks!
After quite a bit of research, it looks like the Star TSP100/TSP143 LAN is not able to print using Line Mode Commands or ESC/POS from Linux: the solution has been to generate a PDF from HTML (using wkhtmltopdf) and then print the PDF using the node printer library (https://github.com/tojocky/node-printer). I have not yet found a better way to properly format prints.

Creating a Print Monitor / Print Handler

I'm having trouble getting started with building a Print Monitor / Print Handler for Windows using Visual Studio 2012 Ultimate with WDK 8. Basically, this is what I am trying to accomplish:
Create a print monitor (something an application can print to) that will generate a file with the content that should be printed (like the default XPS printer or a PDF printer), and then invokes the print handler
Create a print handler that will parse the generated file and do certain actions with it (check to see if certain text is present, upload the file online, etc)
I feel like the print handler part should not be too hard, but starting with the print monitor is what I'm stuck at. What would I do within VS12? I see options for "Printer Driver V4", "Printer Driver V4 Property Bag", and "Printer XPS Render Filter". Should I use one of those templates, and, if so, what would I do within them? Anything pointing me in the right direction would be appreciated!
EDIT:
Just some more clarification - I only need the text from the print output, but I've read from various sources that getting text-only output leads to no output at all from sources like Firefox, etc since they print text as glyphs.
I will be using the print handler to parse the text for keywords and then upload that information to a web server in a specific format. The print monitor just needs to capture and save the text information from whatever application is printing.
As you pointed out in your comments, some applications such as Firefox print using glyph indices instead of characters. In fact, quite a few do and it's becoming more common. What you need is a print driver. The good news is Microsoft has already written it for you and provided you with sample source code in the WDK. Start by reviewing this to understand your options. The Unidriver is perhaps a little simpler but the Postscript driver has the advantage of generating output that can readily be transformed to PDF or other formats that retain text information (as opposed to raster page images that lose all text information). As far as I'm concerned, don't even think about XPS; it's just an all around disaster.
To handle glyph indices, what you'll need to do is add code to the driver's OEMTextOut function that uses the font's cmap tables to translate glyph indices back into character codes. I'm unaware of any public domain libraries that parse font files, so you'll likely have to write your own code to do this. (Hint: If you support only OpenType/TrueType fonts, you'll cover 99% of all printing applications).
Getting the Microsoft sample code to build, install and run is mostly straightforward, but if you're new to the WDK and installing print drivers, plan on spending a week or more on just that. The glyph index translation part is far more complex and you should plan on spending a lot more time on that.

Zebra RZ400 prints an RFID tag, but encodes the subsequent one

I'm trying to use my RZ400 for the first time. I have placed the RFID tags and the ribbon, calibrated the media and sent the
^XA
^RS8
^FO50,50^A0N,65^FDHex Pattern 1^FS
^RFW,H^FD112233445566778899AABBCC^FS
^XZ
instructions from the programming manual and a RFID tag is printed. The problem is that the NEXT tag is the one that gets encoded.
The tags are SMARTRAC 292-2 Belt and the dimensions are 3x0.625 inches. This is a supported tag according to the vendor.
Thanks.
I believe the issue here is the ordering of your ZPL commands.
The ^FO line will print a label with "Hex Pattern 1". However, after printing, it will advance a tag. Try the following code and see if the tag is encoded and then printed on:
^XA
^RS8
^RFW,H^FD112233445566778899AABBCC^FS
^FO50,50^A0N,65^FDHex Pattern 1^FS
^XZ
Hopefully this will solve the issue.
This problem happened to me with the same printer, but printing from Label Matrix software. I was using a Confidex Casey that worked out of the box, but then switched to a Confidex Carrier Pro and the problem started to happen.
This happens because the printer is not properly calibrated with the Tag you are using.
You need to follow the instructions on the Zebra RZ400 Inlay Placement Guidelines for calibrating your Tag. There are three things you can do:
Run the RFID Calibrate command in the front panel of the printer. Try again.
If it's still tagging the next one, then run the command again, BUT use the option RESTORE instead to revert the previous calibration. Try again.
If it STILL doesn't works, you will need to manually calibrate the Pitch value using SetGetDo commands against the printer using the guide in the manual I linked.
Good luck.

Lua WinAPI - Read cell from Microsoft Excel

I am trying to read values from cells of a running Excel 2007 document. I am using the WinAPI extension for Lua. I am currently running on a Windows XP computer (if that matters, but it seems the WinAPI works from XP on.
This is my Excel document:
This is my Lua code:
require 'winapi'
w = winapi.find_window_match('Book1') -- Specify the name of the window
w:show() -- Set the visability
w:set_foreground() -- Bring this window to the foreground
handle = w:get_handle() -- Get window handle
t = {} -- Create a table
w:enum_children(function(w) table.insert(t,w) end) -- Enumerate all children
for k,v in pairs(t) do -- Print out all pairs in the table
print("",k,"=",v)
end
This is my Lua code output:
Does anyone know how I recursively should enumerate in order to find each Cell? Or is there a better way to go about this? The text I want is the "1234". I have not done much Windows programming since I prefer Unix, but it seems like I am on the right track. I just don't know how to progress from here!
I doubt that Excel uses a window for each and every cell in the spreadsheet, so trying to get to the cell by navigating the window hierarchy is likely a dead end.
If possible, I'd recommend exporting the data to a common file type, like comma-separated values, and making your program parse that.
Alternatively, you can read about UI Automation, which is how things like screen readers can access the data in a Windows application's UI. I've never done that, but it looks like it might be a lot of work. Nevertheless, I believe it's the most robust, supported method for trying to get data out of a Windows application via its user interface.

how can I extract text contents from GUI apps in linux?

I want to extract text contents from GUI apps,here are 2 examples::
example 1:
Suppose I opened firefox, and input url : www.google.com
how can I extract the string "www.google.com" from firefox using my own app ?
example 2:
open calculator(using gcalctool),then input 1+1
How can I extract the string "1+1" of calculator from my own program?
in brief ,what I want is to find out whether there is a way to extract the text contents from any widget of an GUI application
Thanks
I don't think there's a generic way to do this, at least not a very elegant one.
Some inelegant ideas:
You might be able to modify the X window system or even some toolkit framework to extract what is being displayed in specific window elements as text.
You could take a screenshot and use an OCR library to convert the pixels back into text for the interesting areas.
You could recompile the apps of interest to add some kind of mechanism for asking them questions.
You could use something like xtest to inject events highlighting the region of interest and copying it to the clipboard.
I believe firefox and gcalctool are for examples only and you just want to know in general how to pass output of one application to other application.
There are many ways to do that on Linux, like:
piping
application1 | application2
btw here is the Firefox command line manual if you want to start firefox on Ubuntu with a URL. eg:
firefox "$url"
where $url is a variable whose value can be www.mozilla.org
That sounds difficult. Supposing you're running X11, you can very easily grab a window picture ( see "man xwd"); however there is no easy way to get to the text unless it's selected and therefore copied to the clipboard.
Alternatively, if you only want to capture user input, this is quite easy to do, too, by activation the X11 record extension: put this in your /etc/X11/xorg.conf:
Section "Module"
Load "record"
#Load other modules you need ...
EndSection
though it may prove difficult to use too, see example code for Xorg/X11 record extension fails

Resources