Printer Control Direct from CDS/ISIS for DOS

Alan Wood
CAB International, 56 Queen's Gate, London, SW7 5JR, UK

In Chapter 4 Section J, the CDS/ISIS 2.3 manual gives brief instructions on how to control printer functions by sending escape sequences within print formats. The examples given are for Epson dot matrix printers, and do not work with the Hewlett-Packard laser and inkjet printers that are common today and that use PCL (Printer Command Language). This paper explains how to send escape sequences, and what sequences are needed for Hewlett-Packard printers.

Escape sequences can apply to the whole document, or be applied to complete fields or subfields. CDS/ISIS assumes that any string in a print format starting with ! is followed by an escape sequence enclosed in delimiters, and it is convenient to use ! as the delimiter character.


Probably the simplest and most useful control code is for bold. The sequence to start bold is (s3B, and the one to return to normal weight is (s0B, and in this example the B must be upper case. So to make field 20 appear in bold we can use conditional literals as follows: !!(s3B!,v20,!!(s0B! If your printer can do it, 7B will set extra bold.

Combining escape sequences

Escape sequences that start with the same 2 characters (such as "(s") can be combined in a single sequence. The alphabetic character that ends the sequence must be upper case, and all other alphabetic characters in the sequence must be lower case.


The sequence to start italics is (s1S, and the one to return to upright is (s0S. So to make field 25 appear in bold italic we need:
Note that this uses two combined escape sequences, each with correct upper and lower case.

Monospaced Fonts

Any typeface that is built into the printer can be used, but CDS/ISIS is much happier with monospaced fonts than with proportional ones. The sequences for some of the common monospaced fonts are:
Courier 10cpi 12 point             !!(s0p10h3T!
Courier 12cpi 10 point             !!(s0p12h3T!
Letter Gothic 12cpi 12 point       !!(s0p12h6T!
Line Printer 16.67cpi              !!(s0p16.67h0T!
Prestige Elite 12cpi 10 point      !!(s0p12h2T!
The 0p sets fixed pitch printing, the number before the h is the (horizontal) spacing in characters per inch, and the number before the T specifies the font.

Fonts are normally applied to a whole document, so are used near the start of a print format.

Proportional fonts

It is possible to specify proportional fonts, but CDS/ISIS will still count the number of characters, not their width, to determine where to break a long line.

The sequences for some of the commoner proportional fonts (specified as 1p) are:

Antique Olive       !!(s1p4168T!
CG Omega            !!(s1p4113T!
CG Times            !!(s1p4101T!
Clarendon Condensed !!(s1p4140T!
Coronet             !!(s1p4116T!
Garamond            !!(s1p4197T!
Helv                !!(s1p4T!
TmsRmn              !!(s1p5T!
Univers             !!(s1p52T!
Univers Condensed   !!(s1p4148T!
There is no fixed pitch, so the h parameter is not used. The (vertical) point size can be specified in a sequence, e.g. for 12 point:
and so the complete sequence for 11 point Univers would be:

Margins and lines per page

These settings can be controlled with escape sequences, but it is much easier to use the facilities provided by CDS/ISIS. You will need to experiment with your own printer and your own choice of font, but you can try these settings as a starting point:
12 point CG Times

Line width 100, Column width 100, lines per page 60, Data indent 15

12 point Univers

Line width 90, Column width 90, lines per page 60, Data indent 13.

Print quality

Print quality can be set to either draft (1Q) or letter quality (2Q). This would normally be used only once in a format, near the start.
Draft quality  !!(s1Q!
Letter quality !!(s2Q!

Special characters

If you need to print special characters, such as £, or accented characters, you may need to specify the character set. This should be specified near the start of the print format, and in a separate escape sequence, not combined with any others. The main character sets are:
PC-8                     !!(10U!
HP Roman8                !!(8U!
ECMA-94 Latin 1          !!(0N!
If your special characters do not come out correctly, try specifying a different character set.


You can specify portrait (vertical page, like this one) or landscape. This must be specified near the start of the print format, and in a separate escape sequence, or combined with paper sizes:
Portrait       !!&l0O!   [ell, zero, capital oh]
Landscape      !!&l1O!   [ell, one, capital oh]

Paper Size

Your printer is probably set to default to the paper size that you normally use, but it is possible to instruct it to use a particular size:
A4             !!&l26A!
US Letter      !!&l2A!
US Legal       !!&l3A!
These escape sequences must be specified near the start of the print format, either in a separate sequence or combined with orientation.


The first time that a print format with proportional fonts is used, the first line always seems to be indented too much. To work around this, print just one record on scrap paper, and then print your complete set of data.

With proportional fonts, titles and page numbers are not centred; they are too far to the left. There is probably no solution to this, except not to use titles and page numbers.

If you want to use a font other than those specified above, or if your printer does not use PCL, you will need to consult the Technical Manual to discover the correct escape sequences.

Sample print format

MDL,!!&l26a0O!,!!(10U!,!!(s0u0p10h12v0s0b3t2Q!,mfn'  ',if a(v10) 

and a(v11) then '[Anon.]  ' else v 10+|; | fi, v11+|;|, 

!!(s3B!,v20,!!(s0B!, "["v21"]",MPL,"In: "v22" ",!!(s1S!,v30" 

",!!(s0S!,v31" ", "("v32")",!!(s3B!," "v33,!!(s0B!," ("v34")"," 

"v35," ISBN "v36,' ['v41+|,|,","v42+|,|,", Price "v43,

", "v44']'," "v45 %##v50(5,0)/(v59*2(5,0)/) %##"DESCRIPTORS:  

"v62+|; |%##

Sample database

A sample database is available for downloading to demonstrate the above.

Please use PKUNZIP (or equivalent) to unzip the file, and then read the README.TXT file.

Alan Wood,, 17 September 1997