please dont rip this site

Integrating Form Overlays Directly into Applications - Using Printer-Resident Forms

Controlling a printer-resident storage device and implementing complex printing operations such as duplexing, multi-bin printing, etc. is much easier than many consultants, software vendors, and technophobes would have you believe. This forms approach will prove to be faster, easier, less expensive and totally open-platform. The e-forms approach is also the most efficient, as it eliminates host-intensive form storage and time-consuming downloads, and allows for immediate printing of each page at the full rated speed of the laser printer.

Find the Macro Number for the Form or the escape sequence for the font.

When forms and fonts are provided, they normally will be accompanied by a report called the Table of Installed Fonts/Macros or by a Status Page or File Directory if an HP SIMM or DIMM or FLASH or disk drive is used, which lists the forms and their macro numbers and fonts and their escape sequences. On a Table of Installed Fonts/Macros, the columns show the line number, file name, macro ID number and, at the far right, the exact escape sequence to use to overlay that form.

File# Name          Orien- Symbol- Fix/  Pitch Point- Style Stroke Size  Escape-Sequence
                    tation  set     PS          size               bytes
  1   FM001P1.MAC   # 11                                                 <Esc>&f11Y<Esc>&f4X
  2   FM001P0.MAC   # 10                                                 <Esc>&f10Y<Esc>&f4X
  3   FM003P0.MAC   # 30                                                 <Esc>&f30Y<Esc>&f4X
  4   FM001P2.MAC   # 12                                                 <Esc>&f12Y<Esc>&f4X
  5   FM003P3.MAC   # 33                                                 <Esc>&f33Y<Esc>&f4X
  6   FM002P1.MAC   # 21                                                 <Esc>&f21Y<Esc>&f4X
  7   FM003P1.MAC   # 31                                                 <Esc>&f31Y<Esc>&f4X
  8   FM004P1.MAC   # 41                                                 <Esc>&f41Y<Esc>&f4X
  9   Resident Macros  0     0 A    1   300.00 12.00    0     0   186866

The font "Resident Macros" is a dummy font that allows the presence of the forms to be detected by the host in printers that support bi-directional interface and readback of installed fonts, since most printers cannot read the presence of form macros. It normally is present only for form sets that are delivered on printer-resident storage devices. Fonts will be listed along with their characteristics and the entire escape sequence to select that font.

A Status Page lists the Type, ID (the Macro ID number of the form or Font ID number), Size, whether or not the item has been password-protected, an Escape Sequence (if other than the standard <esc>&f<ID>Y<esc>&f4X), Comment, Description, Time, and File name if any.

HP LaserJet 6P Printer
Flash SIMM Status Page

Flash SIMM firmware: v3.02 Flash memory used by Fonts: 0
Flash Memory size: 1 Mbyte Flash memory used by Macro: 0
Flash Password: Disabled Flash memory used by Symbol Sets: 0
Free RAM memory: 1130424 Total Flash memory used: 0
Free Flash memory: 738304 Flash memory: 1

Flash SIMM Macros, Bitmap Fonts, Scaleable Fonts and Symbol Sets

Symbol set Pitch Point size Macro ID's 31100-31499 are reserved by FlashSIMM.
Type      ID     Size  Password  Esc Sequence / Comment            Description            Time        File
BitFont 32633    1004   No       <esc>(0A<esc>(s1p12.00v0s0b0T
Macro      10    4768   No
Macro      11    6916   No
Macro      12   18216   No

In the above example, the SIMM is usable in a HP LaserJet 6P printer only and is less than a quarter filled to its 1-MB capacity. Forms with Macro ID numbers 10, 11, and 12 are loaded as well as the "dummy" font, ID number 32633, that allows the presence of the forms to be detected by the host in printers that support bi-directional interface and readback of installed fonts. Most printers cannot read the presence of form macros.

ID Numbers

In any case, each e-form will be associated with an ID number. For the hotel industry, Electronic Forms Plus, Inc, has standardized on the following Macro ID numbers:

Continue below to see how these IDs
are used to select an eForm
ID Hotel Form Type
21 Folio (FOL)
22 Reciept (RCPT)
23 Invoice (INV)
31 City Ledger Statements (NETSTMT)
32 Detail Statements (DETSTMT)
41 Registration Key Packets (REGKEY)
51 Registration (REG)
61 Quick check out forms. (QCHKOUT)
71 Expense Report Detail pages
81 Expense Report Summary pages
91 Reservation Confirmations (CONF)
92 Itenerary
101 AP Checks
111 Travel Agent Checks

Establish Communication

Laser printers communicate with the host in exactly the same way as any other printer, with parallel connection the most common and strongly preferred. If the interface is serial, set the baud rate, start bits, etc. on the printer to the same settings as the host. Try printing a sample (anything) just to make sure the printer is receiving data from the host.

HP PCL 5 Commands

After communication has been established between your host computer and the laser printer, simple commands (consisting mostly of letters and numbers in a compact format) can be sent by your application program or the host operating system to the printer to order it to perform any number of operations. For example, to overlay an eForm on the printer, the printer would need to recieve the command:

Esc &f#y4X

Where the Esc is the Escape Character (disscussed next) and the # is replaced with one of the ID numbers above.

The Escape Character - at the printer.

Each of these commands is preceded by a special symbol called the escape character so that the printer will recognize the letters and digits as a command instead of as printable text. The printer must see an escape character at the start of each command.

 EXAMPLE: To select form number 100 from a printer-resident storage device, the printer must see the escape character followed by &f100Y.

The Escape Character - at the host.

Different host systems may represent and enter the escape character in different ways. On the IBM PC using DOS EDIT, the escape character is entered by pressing CTRL-P and then CTRL-[ and it is displayed as a left pointing arrow. In a BASIC program the escape character would be represented by the command CHR(27). Each host environment should provide documentation for its method of dealing with this special character.

MS Windows systems

When integrating eForms with MS Windows systems, often the best way is to use a font description file (PFM or PCM) that is installed into the printer driver and that adds a new entry to the list of fonts available to the computer when that printer is selected. When any item on a report, document or other printable file in Windows is selected and its font changed to the eForm font, the macro command will be sent to the printer along with a font selection command. The item that is "printed" in this special font can be just a 1 point period, so that it never really shows on the page, but the eForm is still overlayed on the other printed data. This method works nicely in Windows 3.x, '95, '98, 2000 and NT Workstation 4.0.

Non-ASCII systems

Systems not based on the ASCII standard, such as the IBM AS-400, must use a "twinax converter" or other protocol conversion system to communicate with most modern printers. Each converter has its own way of representing the escape character. For example, the PRIAM 8220 twinax converter will send an escape command to the printer each time it receives the special sequence of &%1B&%.

We can help you find the correct way of sending the escape character from your system. Once that is found, no other special codes are needed to implement the full power of PCL.

Sending Commands for Forms

Forms are activated in the printer by sending the Macro ID command to select the macro number, plus one of the Call, Execute, Overlay, or Stop overlay commands as needed.

Name Command Function
Macro ID esc&f#Y The # symbol is replaced with a macro number which all following Macro commands will act upon.

Followed by one of the following:

Overlay esc&f4X Method 1: Causes the previously specified macro to be overlaid on each page of the job just before it is ejected from the printer.
Settings such as fonts, Lines per inch, etc.. will be returned to their previous settings with the macro is finished.
This command can be sent anywhere on the first page of the job. It is best to allocate space for this command at the very beginning of each page; prior to any print data. If printer reset commands are not being sent at the beginning of each job the following must be used to stop the e-form overlay from affecting subsequent jobs:
Name Command Function
Stop Overlay esc&f5X Stops the automatic overlay of all macros.
This command must be sent after the last page of the job is ejected, but before anything is printed on the next page. If this command is combined with any characters (even a space or a carriage return or line feed) a blank page may be ejected before the start of the next job.
Call esc&f3X Method 2: Causes the previously specified macro to be overlaid on this page only immediately.
Settings such as fonts, Lines per inch, etc.. will be returned to their previous settings with the macro is finished. The current cursor position (position at which the next character will be printed) may not be restored.
To avoid possible complications, this command should be sent after the last piece of data is printed on the page, but just before the page is finished (ejected).
Execute esc&f2X Causes the previously specified macro to be overlaid on this page only immediately.
Settings such as fonts, Lines per inch, etc.. will be changed by the macro.

 For example, form number 101 will be enabled for automatic overlay by the command esc&f101Yesc&f4X.

E-Form data formatting

When a new e-forms system is being implemented, the developer can save time by not positioning the variable data. Just print each piece of data with esc&f#yX in front of it and esc&f1X after it. Replace # with a unique ID number for each data item, starting with 1000. The first piece of data (perhaps the date) is 1001, the next piece (perhaps the customer name) is 1002, and so on.  

We have standard lists for MICR check data, Folios, City Ledger Statement, Registration, Conformations, transaction forms, etc... If you need aditional data items, please email us with a list and we will assign a new id number.

Next, select the form via the Macro ID command and use the Macro Execute command. The macro can now position each bit of data, and select its font, size, color, etc... There is no need to send a data item more than once as the Macro can print each data item any number of times in any position, font, size, etc... This allows your customers to have the data printed in a more attractive format and to move the data or emphasise an item at any time via a new or updated e-form.

For example, a hotel may decide that they wish to print a name tag on special stock for each guest registration. The cost of changing the print positions of the data in the program would make this cost prohibitive but with this method, one e-mailed e-form is all that is required.


Data Description
escE Reset the printer and prepare for a new page (not always required but a good idea)
esc&l2a0O Since no data has actually been printed yet (just recorded), we can also setup the page size, tray, etc...  at this point.
esc&f21Yesc&f4X Tell the printer which e-form to overlay (for a page of coupons, check face, registration, invoice, etc..) and now, print and record all the data to fill it out.
esc&f1035yX10/10/99esc&f1X expires 10/10/99. Since this is being recorded in the printers memory, even though the program only sends it once, the e-form can print it as often as you like, anywhere on the page, and in any font.
esc&f1021yX1234esc&f1X reservation number 1234. This could even be printed on the e-form in Barcode 3 of 9 for scanning as well as in human readable text anywhere on the page, in any font and as often as you like.
esc&f1001yXJames Newtonesc&f1X James Newton is the guest. E-forms data formatting allows the customer name or other important data to be highlighted by printing it slightly larger, a little bold or in italics, or in a different typeface...


esc&l0H Eject the page (or you can print an ASCII form feed character)


Don't make it more complex than just recording the data as you would normally print it. If you are printing some linefeeds or carrage returns to move down to a given line and then printing tabs, spaces or using an "@" command to move to a column, just go ahead and do all that, but when you print the data, just print it again with the recording sequences. For example:
FOR I=1 TO 5:PRINT:NEXT:REM move to line 6
PRINT @COL(10),GN$:REM Print the Guest Name

should become

FOR I=1 TO 5:PRINT:NEXT:REM move to line 6
PRINT @COL(10),GN$+chr(27)+"&f1001yX"+TRIM(GN$)+chr(27)+"&f1X":REM Print the Guest Name and record it as 1001

It's a good idea to record only the data without leading or trailing spaces so we added a TRIM() to the data since this language had that function available.

If the language you are using supports function definitions, you can define one that simplifies and centralizes the recording and printing of the data. For example:

DEF FNP$(ID, DATA$)=IIF(LASER, DATA$+chr(27)+"&f"+STR$(ID)+"yX"+TRIM(DATA$)+chr(27)+"&f1X", DATA$)
REM If LASER is true, then print the data and record it in a macro, if useing an impact printer just print the data
FOR I=1 TO 5:PRINT:NEXT:REM move to line 6
PRINT @COL(10),FNP$(1001,GN$):REM Print the Guest Name

Printing the data as we normally would in addition to recording it allows us to use the same program for pre-printed laser forms and for e-Forms. If the e-Forms aren't installed in the printer, the recordings will just be ignored. If the customer upgrades to e-Forms, no effort has to be taken on the software support side to enable them.

Please keep in mind that these recordings of the data will persist untill the printer is reset (via an escE command, etc..) or untill they are recorded over. If your program conditionally prints data, make sure you are resetting the printer at the beginning of each page or record a "blank" for each ID number of the data you may not be printing.

For example:

IF A$>"" THEN PRINT GN$:REM Don't print Guest Name if there is no requirement.

Might be converted to:

IF A$>"" THEN PRINT GN$+chr(27)+"&f1001yX"+TRIM(GN$)+chr(27)+"&f1X":REM Don't print Guest Name if there is no requirement.

But if two pages were printed and A$ was not empty on the first and was empty on the second AND no escE was printed between the pages, the second page would print the $GN value from the first page. It should, instead be done like this:

IF A$>"" THEN PRINT GN$+chr(27)+"&f1001yX"+TRIM(GN$)+chr(27)+"&f1X" ELSE PRINT chr(27)+"&f1001yx1X"

or like this:

PRINT chr(27)+"&f1001yx1X":IF A$>"" THEN PRINT GN$+chr(27)+"&f1001yX"+TRIM(GN$)+chr(27)+"&f1X"

or best of all, just print the escE before starting each new page as recommeded above.


When adding the commands for e-form selection, we strongly recommend:

  1. Not "hard coding" the commands. Instead, place them in an "initialization" file or record, read them from this configuration storage area when the application data is printed. This allows future customer improvements and changes to be implemented at minimal cost. In the examples shown on this page, each string could be replaced with a variable containing that string as loaded from a configuration file. For the escape or other control characters, use a search or replace function to change a string like <esc> into the single escape character. For example:
    REM In the initialization code (this could also read the strings from a data base record or file)
    REM Define Function for printing data at the start of the report program
    DEF FNP$(ID, DATA$)=IIF(LASER, DATA$+RecordID$+STR$(ID)+RecordStart$+TRIM(DATA$)+RecordStop$, DATA$)
    REM If LASER is true, then print the data and record it in a macro, if useing an impact printer just print the data
    REM Then print the data
    FOR I=1 TO 5:PRINT:NEXT:REM move to line 6
    PRINT @COL(10),FNP$(1001,GN$):REM Print the Guest Name
  2. Include space for other powerful PCL commands such as

    These commands must be issued at the very beginning of each printed page; after the reset and prior to any other data being printed. If the Overlay command is being used, and is sent at the very beginning, these commands can be added very easily. Even when using the Call command (from the very end) it is a great idea to also allocate space for a PCL command at the beginning of each page.

  3. Your customers are going to love e-forms: Expect that all your customer will want them and don't limit changes to only the requesting customer's program. PCL e-forms commands will be ignored by PCL printers without e-forms installed and for the most part by older impact printers as well. Consider adding this exciting capability as a standard feature in your program.

Sending Commands for Font Selection

Fonts are selected by sending a PCL command in the format shown below:

 Please note that there is no way to "un-select" a font after it has been selected. To return to the font used previously, you must issue the font selection string for that font. The standard fonts resident in the printer will be listed on the font printout produced by the printer when "TYPEFACE LIST" or "PCL TYPEFACE LIST" is selected from the printer's front panel. See your printer manual for directions on printing this list.

MICR fonts are available for printing bankable checks on plain check stock.



file: /Techref/language/pcl/efpint.htm, 27KB, , updated: 2017/7/20 10:15, local time: 2024/5/23 06:29,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> Integrating Forms Overlay and Fonts Directly into Applications</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!