Articles

Printer Control Codes in Escape

This document discusses Escape's ability to send printer control codes to your printer. This allows your printer to automatically be set to print in condensed mode and/or landscape mode when the report requires it. For the most part, the discussion will focus on Hewlett Packard Laserjet printers, although the concept can be used to control almost any printer. We will discuss the following:

  • Overview of printer setup
  • How to access printer setup
  • What are "escape sequences"?
  • Examples of escape sequences
  • Where to find the escape sequences for your printer

Overview of Printer Setup

The printer setup screen is the way to tell your printer how to print the report. It needs to know what orientation the paper needs to be in (portrait or landscape), what size to print the text on the page, what font to use, how many lines to print on a page, and much more. More than one printer can be set up for each user. This is a great feature because you may want to print one type of report to one printer, and all other types to another printer. For instance, you want PO's to print to one printer and all other reports to print to another.

How to Access Printer Setup

You access printer setup in user records. After accessing a user record, place the cursor in the field under Printer and to the right of 80 column. Press SHIFT-ENTER to bring up a look up window of all the printers currently setup. Press F2 to add a new printer or CTRL-ENTER to modify an existing printer setup. This opens the printer setup screen and will look like this:

TIP: Try using the "HP LJET2" definition. If you purchased a new HP Laserjet or your laser emulates HP, the escape sequences already set up for the HP LJET2 will probably work. Enter the name of the printer you are setting up in the EDITING PRINTER SETUP FOR box. The box to the right of the name of each report type is the CAN DO box. Place a one in this box if you want Escape to carry out the escape sequences, otherwise place a zero in the box. Placing a zero in the box tells Escape to ignore the escape sequences for that report type. Now you need to enter the escape sequences, but...

What Are Escape Sequences?

Escape sequences are the individual commands you send to the printer that tell it to print landscape or portrait, which font to use, number of lines per page, etc…. Escape sequences are so named because they start with the character defined as the ESC key on your keyboard, or the binary equivalent.

To put the correct escape sequences in for each report type, you first have to know what you want to tell the printer to do. We call these the "English commands." The table below lists the "English" commands you would most commonly use for each report type.
Report Type English Commands
80 Col Rpt Portrait 10cpi 66 lines per page
132 Col Rpt Portrait Condensed (17.6cpi) 66 lines per page
Letter Portrait 10cpi 66 lines per page
Misc. Rpt 1 Portrait 10cpi 66 lines per page
Misc. Rpt 2 Portrait 12cpi 66 lines per page
Extra Wide Landscape Condensed (17.6cpi)

Some things to note:

  • cpi - characters per inch
  • lines per page - most HP printers use VMI (vertical motion index). The value 7.27 is for 66 lines per page. The number of lines per page for landscape mode is 48, although, you won't have to worry about putting that in an extra wide report because the printer will default to 48 lines per page for landscape mode.

Examples of escape sequences

Most of these common escape sequences are the same for all HP printers:

English Command Escape Sequence
Portrait @ES&l0O
Landscape @ES&l10
10 CPI @ES&K0S
Condensed @ES&K2S
66 lines per page @ES&l7.27C

l = the lower case L, 0 = the number zero, O = the upper case O

DO NOT include spaces when you group several commands together. For example, a string of escape sequences for an 80 column report would look like:

@ES&l0O@ES&K0S@ES&l7.27C

That group of escape sequences means: Portrait, 10cpi, 66 lines per page

Some things to note:

@ES - means ESC. It may be labeled as ESC, @ES or EC in your printer manual. You need to enter it as @ES in Escape.

Some of the new printers allow you to define the number of lines per page as where # is the number of lines you want per page.

If your reports are not aligning properly you may need to change your font. The best way to choose a font is by printing a font list from the printer. Your manual will show you how to do this. The font should be a fixed width font (as opposed to proportional space) that supports line drawing. Most PC-8 charter set fonts are fixed width and support line drawing. You'll know if your font doesn't support line drawing because there will be a bunch of funny characters on your reports where lines should be.

The above escape sequences should work on all Laser printers. Most major manufacturers emulate HP's escape sequences so if you copy the escape sequences above you should have luck in setting up your new printer.

Where to Find the Escape Sequences for Your Printer

The escape sequences for your printer are located in your printer manual. They are probably in a Printer Commands section. Unfortunately, it is not possible for us to have a copy of all printer manuals, but you could always fax us a copy of the printer commands from your printer manual so we could offer more assistance on your printer setup.