Difference between revisions of "VISTA Advanced printing topics"
(→Advanced troubleshooting) |
DavidWhitten (talk | contribs) (→Setting Up a Printer in VISTA) |
||
(31 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
= Advanced Printing Topics = | = Advanced Printing Topics = | ||
− | Authored mainly by Sam Habiel, the printer "sensei" | + | Authored mainly by [[Sam Habiel]], the printer "sensei." |
− | + | __TOC__ | |
− | |||
− | == VISTA and | + | == How do Computers Communicate with Printers, Software-wise? == |
− | VISTA sends PCL5 to printers. | + | 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. Commercial label printers (like Zebras) always accept their own programming language (ZPL). |
+ | |||
+ | == 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 using 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. Consult the printer manual to find out how to 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 nothing 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" | ||
+ | <pre> | ||
+ | $ nc -v 10.10.10.128 9100 <<< "TEST" | ||
+ | </pre> | ||
+ | |||
+ | and here's an example printing a Datamatrix code on a Zebra printer: | ||
+ | <pre> | ||
+ | $ nc -v 10.10.10.128 9100 <<< "^XA^FO50,100^BXN,10,200^FDTESTTEST^FS^XZ | ||
+ | </pre> | ||
+ | |||
+ | A successful connection will look like this: | ||
+ | <pre> | ||
+ | Connection to XX.XX.XX.XX 9100 port [tcp/jetdirect] succeeded! | ||
+ | </pre> | ||
+ | |||
+ | An unsuccessful connection will either just hang or tell you connection refused. | ||
+ | <pre> | ||
+ | nc: connect to XXXXXXXXX port 9100 (tcp) failed: Connection refused | ||
+ | </pre> | ||
+ | |||
+ | == 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 the [[Setting_up_a_VISTA_Printer]] page. | ||
== Testing Printers == | == Testing Printers == | ||
− | To test printers in VISTA after setting it up, there are a few steps you have | + | To test printers in VISTA after setting it up, there are a few steps you have to go through. |
+ | |||
+ | If you run this on Caché, Caché steals your IO device between prompts. Therefore U IO to D ^%ZISC need to be on a single line. For example, | ||
+ | |||
+ | <pre> | ||
+ | U IO W "TEST",!,"TEST",! D ^%ZISC | ||
+ | </pre> | ||
Invoke via %ZIS first. | Invoke via %ZIS first. | ||
Line 23: | Line 66: | ||
</pre> | </pre> | ||
− | 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 [[Setting_up_a_Linux_Printer | + | 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, as explained on the page: [[Setting_up_a_Linux_Printer]]. |
− | The next menu option to try is Send Test Pattern to Terminal [XUTTEST]. If that works, then you are good to go. | + | The next menu option to try is <nowiki>Send Test Pattern to Terminal [XUTTEST]</nowiki>. If that works, then you are good to go. |
− | == Various | + | == Various Troubleshooting Topics -- How Fun! == |
− | There are various | + | There are various issues that come up regularly with VISTA. |
+ | === Laser Printer Issues === | ||
Use this page as a reference for PCL: | Use this page as a reference for PCL: | ||
http://www.pclviewer.com/resources/reference/ | http://www.pclviewer.com/resources/reference/ | ||
− | === Extra | + | ==== Extra Pages ==== |
Extra pages can happen for three different reasons: | 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 | + | * 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 that this be disabled. To disable the extra page, you can do it at the device level or the terminal type level. At the device level, set <code>SUPPRESS FORM FEED AT CLOSE</code> to yes. For the terminal type, set <code>CLOSE EXECUTE</code> to <code>S IONOFF="" W $C(27)_"E"</code> |
* 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. | * 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. | * 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. | ||
− | === Wrapping === | + | ==== Wrapping ==== |
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. | 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. | ||
Line 50: | Line 94: | ||
* 14 cpi 6 lpi Landscape (132 wide reports) | * 14 cpi 6 lpi Landscape (132 wide reports) | ||
* 22 cpi 12 lpi Landscape (228 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: | ||
+ | <pre> | ||
+ | ^XA^PW707^XZ | ||
+ | </pre> | ||
+ | |||
+ | 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 or 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. | ||
+ | |||
+ | === Advanced Troubleshooting === | ||
+ | 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; or ZPL II and use a Zebra emulator. | ||
+ | |||
+ | To capture an output from VISTA, you need to create a device whose type is HFS but whose destination is pre-determined. Here's an example: | ||
+ | |||
+ | <pre> | ||
+ | NAME: SAM-DIRECT-HFS-PRINTER $I: /tmp/op-dev6-lbl-sam.pcl | ||
+ | LOCATION OF TERMINAL: File | ||
+ | OPEN PARAMETERS: "NWS" SUBTYPE: P-HPLJ4SI-P12 | ||
+ | TYPE: HOST FILE SERVER | ||
+ | </pre> | ||
+ | |||
+ | If you want to change the file for each job, so that they won't overwrite each other, you can append something to IO in the pre-open execute. Please note that you need to change "NWS" to (newversion) on GT.M. | ||
+ | |||
+ | This is the emulator I use for PCL, http://www.ghostscript.com/GhostPCL.html. | ||
+ | This is the emulator I use for ZPL II, http://labelary.com/viewer.html | ||
+ | |||
+ | To use GhostPCL, here is a sample invocation: | ||
+ | |||
+ | <pre> | ||
+ | cat vista_print-0001.pcl | C:\Users\shabiel\workspace\ghostpcl-9.15-win32\pcl6-9.15-win32.exe -dBATCH -dSAFER -dNOPAUSE -sDEVICE=pdfwrite -r600 -sOutputFile="testpdf.sam" - | ||
+ | </pre> | ||
== Typical PCL String == | == Typical PCL String == | ||
Line 59: | Line 160: | ||
* Set Line Carriage mode (CR, CRLF, or LF) | * Set Line Carriage mode (CR, CRLF, or LF) | ||
* Set Orientation (Portrait or Landscape) | * Set Orientation (Portrait or Landscape) | ||
− | * Set Character Set (optional; not needed for US printing; may need to Spanish) | + | * Set Character Set (optional; not needed for US printing; may need to change for Spanish) |
* Set Margins (optional; but you will probably need it at some point) | * Set Margins (optional; but you will probably need it at some point) | ||
* Set Font | * Set Font | ||
Line 72: | Line 173: | ||
... ; Character Set Omitted | ... ; Character Set Omitted | ||
W *27,"&l4E" ; Top Margin 4 lines | W *27,"&l4E" ; Top Margin 4 lines | ||
− | W *27,"&a5L" ; Left | + | W *27,"&a5L" ; Left Margin 5 columns |
W *27,"(s0p12h0s0b4099T" ; Fixed Pitch; 12 cpi, fixed pitch for secondary font, Medium Weight, select courier font. | W *27,"(s0p12h0s0b4099T" ; Fixed Pitch; 12 cpi, fixed pitch for secondary font, Medium Weight, select courier font. | ||
</pre> | </pre> | ||
Line 146: | Line 247: | ||
</pre> | </pre> | ||
− | == | + | == Printing PDFs from VISTA == |
− | + | Using GhostPCL, you can directly print out a PDF from VISTA. Here's an example in GT.M on Linux: | |
+ | |||
+ | <pre> | ||
+ | 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 | ||
+ | </pre> | ||
+ | |||
+ | An example on Cache on Linux: | ||
− | + | <pre> | |
+ | NAME: GHOSTPCL PORTRAIT | ||
+ | $I: /home/lxuser/bin/gpcl6 -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=/opt/HFS/shabiel/print_out.pdf - | ||
+ | LOCATION OF TERMINAL: PDF to /opt/HFS | ||
+ | OPEN COUNT: 8 OPEN PARAMETERS: "qw" | ||
+ | POST-CLOSE EXECUTE: N % S %=$ZF(-1,"sh -c 'mv /opt/HFS/shabiel/print_out{,`date -Iseconds | tr \: _`}.pdf'") SUBTYPE: P-HPLASER-P12 | ||
+ | TYPE: TERMINAL | ||
+ | </pre> | ||
− | + | On Windows, you can add a Windows printer that automatically calls GhostPCL. You need to use this amazing piece of software: | |
+ | http://sourceforge.net/projects/mfilemon/ | ||
+ | |||
+ | 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 | ||
<pre> | <pre> | ||
− | + | $ lpstat -v | |
+ | |||
+ | device for TEST-01: socket://192.168.10.3:9100 | ||
+ | |||
+ | device for TEST-02: socket://192.168.10.4:9100 | ||
</pre> | </pre> | ||
− | + | == Finding the Ready Status of a Print Queue == | |
+ | |||
+ | On Linux, the lpstat command tells you all the printers and what their status is. | ||
+ | <pre> | ||
+ | $ 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 | ||
+ | </pre> | ||
+ | Or for a particular printer: | ||
<pre> | <pre> | ||
− | + | $ lpstat -p TEST-03 | |
− | + | ||
− | + | printer TEST-03 is idle. enabled since Fri 17 Mar 2017 08:39:00 AM EDT | |
− | + | Ready to print. | |
− | |||
</pre> | </pre> |
Latest revision as of 01:37, 12 April 2022
Advanced Printing Topics
Authored mainly by Sam Habiel, the printer "sensei."
Contents
- 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.8 Typical PCL String
- 1.9 Advanced Functions
- 1.10 Printing PDFs from VISTA
- 1.11 Finding the TCP/IP address for a print queue name
- 1.12 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. Commercial label printers (like Zebras) always accept their own programming language (ZPL).
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 using 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. Consult the printer manual to find out how to 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 nothing 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 the Setting_up_a_VISTA_Printer page.
Testing Printers
To test printers in VISTA after setting it up, there are a few steps you have to go through.
If you run this on Caché, Caché steals your IO device between prompts. Therefore U IO to D ^%ZISC need to be on a single line. For example,
U IO W "TEST",!,"TEST",! D ^%ZISC
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, as explained on the page: Setting_up_a_Linux_Printer.
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 issues that come up regularly with VISTA.
Laser Printer Issues
Use this page as a reference for PCL:
http://www.pclviewer.com/resources/reference/
Extra Pages
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 that this be disabled. To disable the extra page, you can do it at the device level or the terminal type level. At the device level, set
SUPPRESS FORM FEED AT CLOSE
to yes. For the terminal type, setCLOSE EXECUTE
toS 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.
Wrapping
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:
^XA^PW707^XZ
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 or 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.
Advanced Troubleshooting
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; or ZPL II and use a Zebra emulator.
To capture an output from VISTA, you need to create a device whose type is HFS but whose destination is pre-determined. Here's an example:
NAME: SAM-DIRECT-HFS-PRINTER $I: /tmp/op-dev6-lbl-sam.pcl LOCATION OF TERMINAL: File OPEN PARAMETERS: "NWS" SUBTYPE: P-HPLJ4SI-P12 TYPE: HOST FILE SERVER
If you want to change the file for each job, so that they won't overwrite each other, you can append something to IO in the pre-open execute. Please note that you need to change "NWS" to (newversion) on GT.M.
This is the emulator I use for PCL, http://www.ghostscript.com/GhostPCL.html. This is the emulator I use for ZPL II, http://labelary.com/viewer.html
To use GhostPCL, here is a sample invocation:
cat vista_print-0001.pcl | C:\Users\shabiel\workspace\ghostpcl-9.15-win32\pcl6-9.15-win32.exe -dBATCH -dSAFER -dNOPAUSE -sDEVICE=pdfwrite -r600 -sOutputFile="testpdf.sam" -
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:
- Reset
- 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 change for 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 Margin 5 columns W *27,"(s0p12h0s0b4099T" ; Fixed Pitch; 12 cpi, fixed pitch for secondary font, Medium Weight, select courier font.
Advanced Functions
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
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
An example on Cache on Linux:
NAME: GHOSTPCL PORTRAIT $I: /home/lxuser/bin/gpcl6 -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=/opt/HFS/shabiel/print_out.pdf - LOCATION OF TERMINAL: PDF to /opt/HFS OPEN COUNT: 8 OPEN PARAMETERS: "qw" POST-CLOSE EXECUTE: N % S %=$ZF(-1,"sh -c 'mv /opt/HFS/shabiel/print_out{,`date -Iseconds | tr \: _`}.pdf'") SUBTYPE: P-HPLASER-P12 TYPE: TERMINAL
On Windows, you can add a Windows printer that automatically calls GhostPCL. You need to use this amazing piece of software:
http://sourceforge.net/projects/mfilemon/
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.