ASCII commands to printer via printjob?

Is there any simple way to send ascii data to a printer using createPrintJob (or some other way) without the data being converted to a raster image of the component first?

The documentation is a little misleading by saying “Provides a general printing facility for printing the contents of a window or component to a printer.” I want to print the contents of a TextArea (i.e. text), NOT an image of the TextArea component.

Thanks.

There isn’t currently a way to print in that way. If you use the createPrintJob it will print the entire component including the text.

You could work around this by using the Reporting Module.

EDIT: Sorry for the choice of words. I dont know if there will be a feature in the future or not, but currently there is not a way to print the way you would like.

What exactly are you trying to do? What kind of printer is it, and how are you communicating with it? I use several kinds of printers that require escape characters, so you can definitely do it from Ignition.

We have a similar issue with some barcode printers that need to get a stream of text. Any info on how to do this via ignition would be greatly appreciated.

Yes, it is a Zebra barcode printer that uses ZPL code (ascii). I don’t want to have to re-invent a print queue, so it should be as easy as setting up a printer in the OS and printing to it. The current printJob thing is useless to me. I can’t see a need to print the component as a whole as a raster image. Maybe some people have that need, but I would think in a shop environment it would be more likely to need to print ascii.

Greg, why would there never be a way to print this way?

How am I to work around the problem by using the reporting module? Do I have to save to a file first in order to do this, then point the control to the file and also hide the control because I only need it to print? This is certainly a work around (hack). So far I have believed Ignition to be better than that.

Also, trying to use the TCP driver, I have had no luck viewing responses (from any device actually) from the printer. The message tag is always stale. I need to know if a barcode gets printed, and if not make sure it does. Using the existing OS print queue would be better for this, don’t you think?

I have had limited success writing actual socket code. I can print sometimes but mostly get blocking errors, etc. and I also don’t want to have to reinvent queing code.

So is there no easy way to print ascii from Ignition?

Thanks.

So, Printing to a zebra, just text?
Maybe use
system.file.writefile to create a text file w/ the text, then call system.util.execute to execute the print command from the OS.

I print to Zebras as well as several other printers. In the case where it is a serial printer, I just use an ethernet-serial converter so my code is the same.

To do this, I don’t use any built-in Ignition functions. There very well could be a function that would work fine, but my personal preference is to create my own in Python. To each his own.

For one printer that uses a serial converter, I use UDP. The following code works nicely:

import socket
import system
udpSocket=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
message ="SEND THIS TO ZEBRA"
ip='192.168.0.100'
port=20000
udpSocket.sendto(message,(ip,port))

This has worked reliably for years. I do something very similar with TCPIP, and there are some threads in the forum discussing it. Also, remember you have both python and java sockets available to you, so just start hacking and I’m sure you will figure something out.

Thanks guys! I’m testing these two suggestions out now. Sorry for my last post. It was a bit overboard due to current deadlines.

I can’t believe I missed the system.util.execute thing. I guess it really is in the last place you look!

I am glad that you were able to get some suggestions from other Ignition users.

I made an edit to my last post. I will reiterate it here. I did choose the wrong wording for that post. Its not that we will never incorporate that functionality, its that we don’t currently have it. You can certainly post it as a feature request in the feature request forum.

Thanks Greg, I will post a request. I’m using system.util.execute to have notepad print the ascii to the printer, but it would certainly be less points of failure if it could be done from inside Ignition.

agreed. I am glad to hear that you were able to get it working though.

Hi guys I also require to send information to a label printer via text file, this is the format required.

#!A1
#!MS60/85
#!ER
#!J14.6#T74.8#YB4/1OP2.5/30.0/6///{Barcode Number Tag}#G
#!Q1

I have racked my brain a bit trying to work out the best way. The barcode number tag will come from a created tag based on Julian date. Also require the CR between the lines.
Can someone assist with the best method or script please? I would like to run this automatically.
Much appreciated.
hazey

Take a look at this post and see if it helps: viewtopic.php?f=70&t=9727

Dave thanks, that OP is sending data direct to the printer, I will see what my printer can handle. I know it does look for a text file with the code inside it, but there may be another way around.

thanks

hazey