The Euro Macros for LaserJet Printers

In January 2002 twelve European currencies were replaced by one common currency, the Euro. Because of this, many programmers were facing the problem of updating their old DOS-based applications with support for the Euro character. The solution described in this document may be suitable for some of those programmers but definitely not for all.

First of all, it is a solution for printing the Euro character, not for displaying it on screen. Also, it will only work on the HP LaserJet 4 and newer HP laser printers and on LaserJet compatible printers from other manufacturers. It will not work on dot matrix or ink printers or on laser printers that do not support the PCL5 printer control language. It is also only designed for those who print in character mode using the built-in fixed pitch Courier font of the laser printer. In this document, all supported printers are referred to as LaserJet printers regardless of manufacturer.

The demo that accompanies the Euro macro file is written in Clipper, but the principles for using the Euro macros are in no way specific to any programming language. But, as mentioned above, they are specific to the targeted type of printer.

Download the Euro macro files here

What is a macro?

One feature of the PCL5 printer control language is the capability to use overlay macros, that is, pieces of PCL code that are pre-loaded into the printer and called with special commands embedded in the character stream when normal text is sent to the printer. The overlays can be as small as just one character (that is the nature of the Euro macros) when printed on paper, or they can be complete forms with truckloads of text and graphics, or they can be anything between those two extremes.

"Pre-loaded" means that in order to use a macro you have to either download the macro file into the printer before your application is started or use a function within your application to download it at the beginning of the document you want to print. In the case of the Euro macro, the macro file is only about 12 KB, so the download time is negligable.

Macros can contain anything that is printable. In addition to plain text, this includes lines and boxes drawn with PCL or HP-GL code as well as graphic images. The latter need to be converted to PCL code before they are downloaded. Of course, macros can (and do) also contain a variety of commands for controlling the printer's behaviour.

Macros can be either temporary or permanent. Temporary macros are automatically deleted from the printer's memory after execution. Permanent macros are not deleted until a specific delete command is sent to the printer or the printer is powered down. A printer reset does not delete permanent macros. The Euro macros are of the permanent type, so there is no need to download them more than once after the printer has been powered up.

Macros that contain graphics, as is the case with the Euro macros, must be downloaded as binary, that is, if the COPY command in DOS is used, the /B switch must be supplied. If you download the macros into the printer from inside your application, the printer port must first be set to RAW mode. Failure to do so will result in corruption of the graphic images.

Each overlay macro must have a macro number for identification. The macro number is coded into the character stream that the printer reads when the macro file is downloaded. The same number must be supplied by the calling code in order to execute the macro. Please note that the macro number must be a string of numerical characters and not a numerical value.

If a macro with the same number as one of the macros provided in this package is already downloaded into the printer it will be overwritten, which may interfere with printing of other documents. Conversely, if another macro with the same macro number as one of the Euro macros is downloaded into the printer after downloading the Euro macro file, printing of the Euro character will fail.

Font attributes for the Euro macros

The Euro macros that are included in the accompanying binary file EURO.HP4 are a whole collection of 24 different overlay macros, each for a specific printing need but all designed to conform with the style of the Courier typeface.

There are three different pitches: 10, 12 and 17 (or 16.67) characters per inch.
There are two different bolding options: Bold and non-bold
There are two different italization options: Italic and non-italic
And finally, there is one version for portrait printing and one for landscape printing for each combination of the three previous attributes.
In all, this makes 3 x 2 x 2 x 2 = 24 different macros. Each macro has its own macro number.

List of macros in the EURO.HP4 file

In Windows, when using a Euro enabled font, a Euro character can be input by holding the <Alt> key and typing 0128 on the numeric keypad. This number, 128, is also used as a basis for identifying the macros in the Euro macro file. This is not done for any technical reason. Its only purpose is to create some kind of familiarity for those working with the macros. But since most macros written for the LaserJet probably use low macro numbers, two zeros have been added to the base macro (10 CPI normal Courier in portrait mode) to make it as unique as possible. So the macro number of the base macro has been set to 12800. Variants are then numerically added to 12800, so the macro numbers of the whole series of Euro macros lie within the 12800 to 12831 interval. But remember that the macro number must be sent to the printer as a string, not a numerical value.

Base macro number       12800      Portrait, 10 CPI, Normal

For variant attributes, add one or more of the following:

Bold                        1

Italic                      2

12 CPI                      4

17 CPI                      8

Landscape                  16

Do not add both 12 CPI and 17 CPI at the same time as the combi-
nation of the two will produce a macro number that does not exist
in the macro file.

Complete macro list:             Base    B   I  12  17   Ls   Total

Portrait,  10 CPI, Normal        12800 + 0 + 0 + 0 + 0 +  0 = 12800

Portrait,  10 CPI, Bold          12800 + 1 + 0 + 0 + 0 +  0 = 12801

Portrait,  10 CPI, Italic        12800 + 0 + 2 + 0 + 0 +  0 = 12802

Portrait,  10 CPI, BoldItalic    12800 + 1 + 2 + 0 + 0 +  0 = 12803

Portrait,  12 CPI, Normal        12800 + 0 + 0 + 4 + 0 +  0 = 12804

Portrait,  12 CPI, Bold          12800 + 1 + 0 + 4 + 0 +  0 = 12805

Portrait,  12 CPI, Italic        12800 + 0 + 2 + 4 + 0 +  0 = 12806

Portrait,  12 CPI, BoldItalic    12800 + 1 + 2 + 4 + 0 +  0 = 12807

Portrait,  17 CPI, Normal        12800 + 0 + 0 + 0 + 8 +  0 = 12808

Portrait,  17 CPI, Bold          12800 + 1 + 0 + 0 + 8 +  0 = 12809

Portrait,  17 CPI, Italic        12800 + 0 + 2 + 0 + 8 +  0 = 12810

Portrait,  17 CPI, BoldItalic    12800 + 1 + 2 + 0 + 8 +  0 = 12811

Landscape, 10 CPI, Normal        12800 + 0 + 0 + 0 + 0 + 16 = 12816

Landscape, 10 CPI, Bold          12800 + 1 + 0 + 0 + 0 + 16 = 12817

Landscape, 10 CPI, Italic        12800 + 0 + 2 + 0 + 0 + 16 = 12818

Landscape, 10 CPI, BoldItalic    12800 + 1 + 2 + 0 + 0 + 16 = 12819

Landscape, 12 CPI, Normal        12800 + 0 + 0 + 4 + 0 + 16 = 12820

Landscape, 12 CPI, Bold          12800 + 1 + 0 + 4 + 0 + 16 = 12821

Landscape, 12 CPI, Italic        12800 + 0 + 2 + 4 + 0 + 16 = 12822

Landscape, 12 CPI, BoldItalic    12800 + 1 + 2 + 4 + 0 + 16 = 12823

Landscape, 17 CPI, Normal        12800 + 0 + 0 + 0 + 8 + 16 = 12824

Landscape, 17 CPI, Bold          12800 + 1 + 0 + 0 + 8 + 16 = 12825

Landscape, 17 CPI, Italic        12800 + 0 + 2 + 0 + 8 + 16 = 12826

Landscape, 17 CPI, BoldItalic    12800 + 1 + 2 + 0 + 8 + 16 = 12827

Macro numbers 12812-12815 and 12828-12831 are reserved

Spacing and cursor positioning

An overlay macro for a LaserJet printer must not change the printer environment. This means that the font selection and font attributes must be identical before and after macro execution no matter what happens inside the macro, the PCL cursor position must be the same, etc. Actually, one of the advantages of using macros in general is that they automatically take care of almost all of those chores. The only significant exception is that the PCL cursor is not automatically returned to the previous location. It is the responsibility of the author of the macro to take care of pushing and popping the cursor position.

The macros in EURO.HP4 are all well behaved, which means that they push the cursor position when they start running and pop it back immediately before returning to the calling code. This also means that printing a Euro character does not advance the cursor. So as far as the surrounding text is concerned, the Euro character does not occupy any space on the printed page. Instead, it is necessary for the calling code to supply a space character after returning from the macro call. This also solves the problem with how the macros are to know exactly how many PCL units they should move the cursor if they were required to re-position it after printing the Euro character. With the implemention described above, the answer is that they do not need to care about that at all.

Since the Euro macros are designed for use with fixed pitch fonts, printing a space after returning from the macro call will align the remaining text on that line perfectly with the text on the rest of the page.

The Euro characters printed by the Euro macros are transparent, which means that any character (space or other character) that is printed in the same position on the page as the macro will show up as a "double exposure" with the two characters printed on top of each other.

The demo program

A demo program is included in the package. As mentioned above, it is written in Clipper. If you are a Clipper programmer, just compile, link and run it. Please note that it is assumed that the printer is connected to LPT1. You may need to change that line in the source code if your setup is different.

The demo consists of the EURODEMO.PRG file and the EURO.CH include file. The include file lists the suggested #defines for building macro numbers for different purposes. It also has a section with #defines for PCL font and attribute selection. Those defines are used in EURODEMO.PRG for combining LaserJet font attribute variants in the surrounding text with the appropriate Euro macro. Feel free to use those defines or to change them to whatever fits the way you normally work (or to skip them entirely).

The demo prints four pages, two of them in portrait mode and two in landscape mode. On each page there are 12 lines of numerical characters with an embedded Euro character in the middle of each line. The 12 lines correspond to the 12 attribute variants in the table above. The first two pages are printed using specific #defines for each font attribute combination (in portrait and landscape mode, respectively) for the text, and the last two pages are printed using "component" #defines which are added together to create the desired font attributes. Please take a look at the include file for details on how to use the #defines. And if you want to use the component #defines for font selection, be sure to read the comments about required and optional components and the order of components, also available in the include file.

The EURODEMO.PRG file also contains a function called Euro(). It adds the different attribute #defines for the Euro character together and returns a string with the complete command for calling the appropriate Euro macro. It also adds the space character mentioned above in the "Spacing and cursor positioning" section, so the cursor position is advanced to the character position after the Euro character.

Don't forget to download the EURO.HP4 file into the printer before running the demo! Again assuming that the printer is connected to LPT1, type  COPY  EURO.HP4   LPT1:  /B

Compatible printers

According to my own tests and to user reports, the Euro macros have so far been tested on the following printers with excellent result (special thanks to Michael Baumann in Vienna who ran the demo application on no less than eight different printers in one single day!):

HP LaserJet 4 family (not tested on 4L)
HP LaserJet 5 family (including 5L)
HP LaserJet 2100
HP LaserJet 40xx family
HP LaserJet 41xx family
HP Color LaserJet 4500 (B&W only)
Ricoh Aficio 350
Kyocera Ecosys FS-3750
Kyocera mita Ecosys FS-1800
Lexmark Optra SC 1275

Some non-HP printers may require special settings before they accept PCL macros. See the technical manual for your printer for info. And the macros will of course only work in PCL mode on those printers that have other emulations in addition to PCL. Some printers may lose the downloaded macros when certain kinds of other jobs ar being printed if there is not enough physical memory present in the printer. This is true for the HP LaserJet 4 family, for example. And in some cases, macros may be lost when the printer enters power saving mode. Again, see the printer manual for suggestions if the macros disappear for no obvious reason.

Terms of usage

You may use the Euro macros and whatever you find useful in the demo program and the include file free of charge in your commercial applications, but you may not sell any part of the package separate from your applications. You may however distribute copies of the entire package, provided 1) that you do not charge anything for them and 2) that this document (The Adobe Acrobat version in EUROMAC.PDF) is included in its entirety. You may not use the Euro macros in applications whose main purpose are to supply the functionality of the Euro macros themselves.

It is up to you to determine whether the Euro macros are suitable for your and your clients' needs and for the printer models you intend to use. It is also your responsibility to make sure that they do not interfere with anything else that is being printed on the printers into which you download the macro file (using the same macro numbers).

The Euro macros (EURO.HP4), the demo application (EURODEMO.PRG), the include file (EURO.CH) and this document are supplied "as is". The author assumes no responsibility for errors, omissions or malfunctions. No liability is assumed for damages resulting from the use of the aforementioned files or any information contained therein. By using any of those files or any part thereof you agree to these terms.


The Euro macros and the files mentioned in the previous section are Copyright (C) 2001-2002 Klas Engwall, Engwall InfoTech AB.


The trademarks mentioned in this document and the accompanying files are the property of their respective owners.

Comments and reports

Feel free to send any comments, problem reports etc to me. However, as this is a non-profit project, I cannot guarantee that I can or will solve any problems or make any enhancements to the package.


EURO.ZIP Download the Euro Macro files
In case you want to talk to me about the Euro Macros
(no general Clipper support questions please)
Back Go back to the Engwall InfoTech Clipper Pages main page

This document was last revised on 2007-10-01