VISTA Advanced printing topics
Advanced Printing Topics
Authored mainly by Sam Habiel, the printer "sensei".
- 1 Advanced Printing Topics
- 1.1 How do computers communicate with printers, software-wise?
- 1.2 VISTA and what it really sends
- 1.3 Communicating with a printer on the network for the first time
- 1.4 Setting up the printer in the operating system
- 1.5 Setting up a Printer in VISTA
- 1.6 Testing Printers
- 1.7 Various troubleshooting topics -- how fun!
- 1.7.1 Laser Printer Issues
- 1.7.2 Zebra Printer Issues
- 1.8 Typical PCL String
- 1.9 Advanced Functions
- 1.10 Advanced troubleshooting
- 1.11 Printing PDFs from VISTA
- 1.12 Finding the TCP/IP address for a print queue name
- 1.13 Finding the ready status of a print queue
How do computers communicate with printers, software-wise?
This is a pretty difficult topic. Cheaper printers only accept binary data that is hardcoded by the computers; typically these printers are only supported on Windows, and thus are named "Winprinters". Higher end printers have a processor on them that can typically interpret PCL5, PCL6, and PS; and possibly PDF. These printers are easily supported in Linux. Commerical label printers (like Zebras) always accept their own programming language.
VISTA and what it really sends
VISTA sends PCL5 to laser printers; or a printer specific language for label printers--most commonly ZPL II for Zebra printers. For laser printers, you need to make sure that your printer supports PCL5. All HP Printers support PCL5, no matter how cheap; other manufacturers only support it on their higher end printers (not too high end--anything that isn't the cheapest printer may support PCL5). If you need to look it up, go to the manufacturer's website and look at the technical specs sheet. The section is typically called "supported emulations"; or "supported languages". What VISTA sends is determined by the sub-type defined for the device.
Communicating with a printer on the network for the first time
Nothing prevents you from doing a USB printer or even a parallel port printer, but in my experience, nobody uses those interfaces in production anymore.
Get the IP address first. You can usually obtain that by printing an information sheet from the printer. You have to consult the printer manual to find out where you can print that information sheet. You can also try to identify the printer from the list of connected hosts on your network.
Whenever I set up a new printer, I tend to ensure that I can talk to it directly, with nobody in the middle. I use the netcat command ('nc') to do that, connecting to the IP address of the printer on port 9100. Make sure to add the -v flag to netcat so that it can report whether it succeeded in connecting at all. It is very possible that you connected to a printer; but you just don't know which one.
(Aside: This can be done from VISTA using D CALL^%ZISTCP(ip_address,port,time_out)--but netcat is easier.)
Here's an example of me trying to talk to a PCL printer, so it will print the word "test"
$ nc -v 10.10.10.128 9100 <<< "TEST"
and here's an example printing a Datamatrix code on a Zebra printer:
$ nc -v 10.10.10.128 9100 <<< "^XA^FO50,100^BXN,10,200^FDTESTTEST^FS^XZ
A successful connection will look like this:
Connection to XX.XX.XX.XX 9100 port [tcp/jetdirect] succeeded!
An unsuccessful connection will either just hang or tell you connection refused.
nc: connect to XXXXXXXXX port 9100 (tcp) failed: Connection refused
Setting up the printer in the operating system
After confirming the connection, you need to set-up the printer in the operating system. VISTA does NOT need any drivers for the printers to be installed.
Setting up a Printer in VISTA
See this page
To test printers in VISTA after setting it up, there are a few steps you have a to go through.
If you run this on Cache, Cache steals your IO device between prompts. Therefore U IO to D ^%ZISC need to be on a single line.
Invoke via %ZIS first.
D ^%ZIS DEVICE: HOME//MY PRINTER U IO W "TEST",!,"TEST",! D ^%ZISC
See the output. If it's okay, you are ready to move to the next step. If you see the "staircase" effect, you need to go back and set-up the terminal type correctly here.
The next menu option to try is Send Test Pattern to Terminal [XUTTEST]. If that works, then you are good to go.
Various troubleshooting topics -- how fun!
There are various issue that come up regularly with VISTA.
Laser Printer Issues
Use this page as a reference for PCL:
Extra pages can happen for three different reasons:
- By default, VISTA prints an extra page after each print job. This is for historical reasons; as most of the early printers were dot-matrix. Today, it's recommended to disable this. To disable this, you can do it at the device level or the terminal type level. At the device level, set
SUPPRESS FORM FEED AT CLOSEto yes. For the terminal type, set
S IONOFF="" W $C(27)_"E"
- The text doesn't fit the page and spills over to the next page. VISTA printing options must follow the IOSL value (Page Length in Terminal Type or Device--Device overrides Terminal Type). Most of the time this has to do with the fact that the text size for the report is too large; or that the margins are not appropriate. Based on visual inspection, you should decide what to do. The unlikely case is that the VISTA programmer is not obeying IOSL; but that is for you to determine.
- If both of the above fail, it's likely that VISTA sends a hard coded form feed to the printer. You need to capture the output by capturing the print to a file (use HFS;subtype) and visually examine it in a programming editor.
Typically this has to do with whether the printer is configured to take 132 characters or 80 characters; if not, then it has to do with the font size.
VISTA has these typical formats for printing:
- 12 cpi 8 lpi Portrait (most reports)
- 17 cpi 7 lpi Portrait (MAR)
- 14 cpi 6 lpi Landscape (132 wide reports)
- 22 cpi 12 lpi Landscape (228 wide reports)
Only a single line prints
You are seeing the staircase effect. See the Staircase section in Setting_up_a_VISTA_Printer.
Zebra Printer Issues
From my memory, these are typically the issues you face:
* Label not aligned vertically * Label not aligned horizontally * Labels are not dark enough. * Label gets cut off * VISTA printed labels are too small
Label not aligned vertically
Zebras mostly auto calibrate printing on continuous media. Check your Zebra's manual on how to do that for the specific model.
Label not aligned horizontally
Zebras don't auto align to the width. You have to set the print width yourself. They can detect the start of the label though.
To do that, find your printer dpi setting, and multiply that by the width of your label. E.g. 202 dpi with 3.5", you need to run this command from the command line:
If that doesn't solve your problem, you need to look carefully at the actual feeding of the label into the zebra printer. Read the manual carefully. I have seen many people "wing it" and do it incorrectly. I have even seen a printer where the left margin guide wasn't used and a rubber band was placed there. After you turn off the restart the printer, it tries to self calibrate.
Label Text is not dark enough
There are two tunable circle things on the top of the print head that can be turned to increase the darkness. Try that. There is also a Zebra setting that can be changed to increase the darkness.
Label gets cut off
If the label gets cut off on the right hand side of the label, check your print width (see 'Label not aligned horizontally'), and if that's not the issue, check the position of the ribbon vis a vis the labels. The printer may be trying to print, but there is no ribbon at the place it's trying to print. If it is getting cut off from the left side, check that your labels are using the left hand guide and are not colliding with it. If it is getting cut off vertically, you need to calibrate the printer. If it still gets cut off, you need to capture the ZPL II that is sent by VISTA and see 1. that it's formatted correctly and 2. that there isn't too much information to print.
VISTA printed labels are too small
This means that you bought a Zebra printer with the wrong dpi. You have to return it and buy another one. VISTA wants printers with 202 DPI. If you want to use the new printer, you need to re-write some of the label code.
Typical PCL String
To construct a PCL in VISTA, you typically put everything in the Open Execute. The Close Execute should always be set to
S IONOFF="" W $C(27)_"E" unless you want to do something special. The Form Feed accepts PCL as well.
The typical PCL sequence for an Open Execute is as follows:
- Set Line Carriage mode (CR, CRLF, or LF)
- Set Orientation (Portrait or Landscape)
- Set Character Set (optional; not needed for US printing; may need to Spanish)
- Set Margins (optional; but you will probably need it at some point)
- Set Font
When constructing a string, I recommend using *27 rather than $C(27) because it's shorter, and you will type a lot of it.
An example. Note that this needs to be all in one string. It's separated here for education.
W *27,"E" ; Reset W *27,"&k2G" ; Set Carriage mode to LF. W *27,"&l0O" ; Portrait; Landscape is 1O. ... ; Character Set Omitted W *27,"&l4E" ; Top Margin 4 lines W *27,"&a5L" ; Left Martin 5 columns W *27,"(s0p12h0s0b4099T" ; Fixed Pitch; 12 cpi, fixed pitch for secondary font, Medium Weight, select courier font.
I won't document this in detail, but here are some advanced examples. These ones do headers.
NAME: P-HP-LTR-POR-C12L6-W80-HD RIGHT MARGIN: 80 FORM FEED: $C(12)_$C(27)_"&f0S"_$C(27)_"&l3E"_$C(27)_"*p2100x,0Y"_$C(27)_"(s1p 16h0s0b16602THEADER"_$C(27)_"(s0p12h0s0b4099T"_$C(27)_"&l4E"_$C(27)_"&f1S"_$P(" #","") PAGE LENGTH: 58 BACK SPACE: $C(8) OPEN EXECUTE: W $C(27,69),$C(27),"&l0O",$C(27),"(0N",$C(27),"&l4E",$C(27),"&a5 L",$C(27),"&k2G",$C(27),"&f0S",$C(27),"&l3E",$C(27),"*p2100x,0Y",$C(27)_"(s1p16h 0s0b16602THEADER",$C(27),"(s0p12h0s0b4099T",$C(27),"&l4E",$C(27),"&f1S" S ($X,$ Y)=0 CLOSE EXECUTE: S IONOFF="" W $C(27)_"E" DESCRIPTION: 12 cpi 6 lpi width 80 standard letter printer
NAME: P-HP-LTR-POR-C17L7-W128-HD RIGHT MARGIN: 128 FORM FEED: $C(12)_$C(27)_"&f0S"_$C(27)_"&l3E"_$C(27)_"*p2100x,0Y"_$C(27)_"(s1p 16h0s0b16602THEADER"_$C(27)_"(s0p17h9v0s0b0T"_$C(27)_"&l4E"_$C(27)_"&l7C"_$C(27 )_"&f1S"_$P("#","") PAGE LENGTH: 64 BACK SPACE: $C(8) OPEN EXECUTE: W *27,"E",*27,"&k2G",*27,"&l4E",$C(27),"&f0S",$C(27),"&l3E",$C(2 7),"*p2100x,0Y",$C(27)_"(s1p16h0s0b16602THEADER",*27,"&l4E",*27,"&f1S",$C(27)," (s0p17h9v0s0b0T",*27,"&l7C" S ($X,$Y)=0 CLOSE EXECUTE: S IONOFF="" W $C(27,69) DESCRIPTION: 17 cpi 7 lpi width 128 standard letter printer (MAR)
NAME: P-HP-LTR-LAND-C22L12-W228-HD RIGHT MARGIN: 228 FORM FEED: $C(12)_$C(27)_"&f0S"_$C(27)_"&l3E"_$C(27)_"*p2750x,0Y"_$C(27)_"(s1p 16h0s0b16602THEADER"_$C(27)_"(s0p22h0s0b4099T"_$C(27)_"&l4E"_$C(27)_"&f1S"_$P(" #","") PAGE LENGTH: 88 BACK SPACE: $C(8) OPEN EXECUTE: W $C(27,69),$C(27),"&l1O",$C(27),"&l4E",$C(27),"&l0D",$C(27),"&k 2G",$C(27),"&f0S",$C(27),"&l3E",$C(27),"*p2750x,0Y",$C(27)_"(s1p16h0s0b16602THEADER",$C(27),"(s0p22h0s0b4099T",$C(27),"&f1S",$C(27),"&l4E" S ($X,$Y)=0 CLOSE EXECUTE: S IONOFF="" W $C(27)_"E" DESCRIPTION: 22 cpi 12 lpi width 228 landscape letter printer (condensed)
NAME: P-HP-LTR-LAND-C14L6-W132-HD RIGHT MARGIN: 132 FORM FEED: $C(12)_$C(27)_"&f0S"_$C(27)_"&l3E"_$C(27)_"*p2750x,0Y"_$C(27)_"(s1p 16h0s0b16602THEADER"_$C(27)_"(s0p14h0s0b4099T"_$C(27)_"&l4E"_$C(27)_"&f1S"_$P(" #","") PAGE LENGTH: 46 BACK SPACE: $C(8) OPEN EXECUTE: W $C(27,69),$C(27),"&l1O",$C(27),"&l4E",$C(27),"&a5L",$C(27),"&k 2G",$C(27),"&f0S",$C(27),"&l3E",$C(27),"*p2750x,0Y",$C(27)_"(s1p16h0s0b16602THEADER",$C(27),"(s0p14h0s0b4099T",$C(27),"&f1S",$C(27),"&l4E" S ($X,$Y)=0 CLOSE EXECUTE: S IONOFF="" W $C(27)_"E" DESCRIPTION: 14 cpi 6 lpi width 132 landscape letter printer
and this one does a watermark:
NAME: P-HP-PORTRAIT-C16L7-WM SELECTABLE AT SIGN-ON: NO RIGHT MARGIN: 96 FORM FEED: $c(27)_"*c5760x6000Y"_$c(27)_"*p150x150Y"_$c(27)_"*c0T"_$c(27)_"%1B IN;SP1;DI1,-1;SD2,1,4,140,6,3,7,4148;SS;PA0,7000;FT10,5;CF2,0;LO21;LBWATERMARK"_$c (3,27)_"%1A"_$c(12) PAGE LENGTH: 60 BACK SPACE: $C(8) *OLD XY CRT: 60 OPEN EXECUTE: W *27,"E",*27,"(8U",*27,"(s0P",*27,"(s16H",*27,"(s9V",*27,"(s0S" ,*27,"(s-3B",*27,"(s0T",*27,"&l88P",*27,"&a255M",*27,"&k2S",*27,"&l7C",*27,"&s1C ",*27,"&k2G" CLOSE EXECUTE: W *27,"*c5760x6000Y",*27,"*p150x150Y",*27,"*c0T",*27,"%1B","IN; SP1;DI1,-1;SD1,21,2,1,4,140,5,0,6,3,7,4148;SS;PA0,7000;FT10,5;CF2,0;LO21;LBWATERMARK" _$C(3),*27,"%1A" DESCRIPTION: HP JL4Si 12 pitch Courier
If you are stuck with a particularly difficult problem, it may be useful to capture the PCL and use a PCL emulator and print to a PDF.
This is the emulator I use, http://www.ghostscript.com/GhostPCL.html.
To use it, here is a sample invocation:
cat vista_print-0001.pcl | sed -e "s/\x1b\[H\x1b\[J/\xc/g" | C:\Users\shabiel\workspace\ghostpcl-9.15-win32\pcl6-9.15-win32.exe -dBATCH -dSAFER -dNOPAUSE -sDEVICE=pdfwrite -r600 -sOutputFile="testpdf.sam" -
You don't need the sed part typically; I added this for interpretation of slave prints.
Printing PDFs from VISTA
Using GhostPCL, you can directly print out a PDF from VISTA. Here's an example in GT.M on Linux:
NAME: PDF WRITER $I: PDF-WRITER LOCATION OF TERMINAL: /tmp/ OPEN PARAMETERS: (comm="pcl6 -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -SOutputFile= /tmp/green-sheet.pdf -")::"pipe" SUBTYPE: P-HP BARCODER TYPE: TERMINAL
On Windows, you can add a Windows printer that automatically calls GhostPCL. You need to use this amazing piece of software:
Once you install it and configure it, you need to set the $I appropriately.
Finding the TCP/IP address for a print queue name
On Linux, the lpstat command tells you details about the print queue
$ lpstat -v device for TEST-01: socket://192.168.10.3:9100 device for TEST-02: socket://192.168.10.4:9100
Finding the ready status of a print queue
On Linux, the lpstat command tells you all the printers and what their status is.
$ lpstat -a TEST-01 accepting requests since Sun 25 Dec 2005 09:54:34 AM EST TEST-02 accepting requests since Thu 28 Nov 2013 09:56:11 AM EST TEST-03 accepting requests since Fri 17 Mar 2017 10:03:00 AM EST
OR for a particular printer:
$ lpstat -p TEST-03 printer TEST-03 is idle. enabled since Fri 17 Mar 2017 08:39:00 AM EDT Ready to print.