AN INTRODUCTION TO PRINTER CONTROL LANGUAGE PCL Printer Language History ============================ Hewlett-Packard created the PCL (Printer Command Language) printer language to provide an economical and efficient way for application programs to control a range of printer features among a number of printing devices. Since original development, HP has evolved both the definition and implementations of the PCL printer language to provide the optimal price and performance balance. The latest version of PCL, PCL 5, represents a new breakthrough in price/performance leadership. Its features were selected in direct response to customer requests. HP will continue to lead enhancements to the PCL printer language in order to deliver powerful technology advances. PCL printer language commands are compact escape sequence codes that are embedded in the print job data stream. This method of sending instructions minimizes both data transmission and command decoding overhead. HP PCL printer language formatters and fonts are designed to quickly translate application output into high-quality, device-specific, raster print images. Printer Consistency ------------------- PCL printer language commonality from HP printer to HP printer helps to minimize printer support problems. More importantly, PCL printer language is used consistently among different printers. This protects the HP printer customer's investment in applications and printer driver software. PCL defines a standard for printer features, and access to those features by software applications. Designed to function independently of the host system, device drivers, interface, and network communication, PCL brings HP printers together under a common and consistent control structure. With feature compatibility from printer to printer, PCL protects the user's investment in application and driver software. PCL Printer Language Architecture ================================= The PCL Printer Language has evolved through five major levels of functionality. The evolution has been driven by the combination of printer technology developments, changing user needs, and application software improvements. The resulting PCL phases, developed over time, partition printer features to align with major printer markets. The five phases of PCL evolution are: PCL 1 Base "Print and Space" functionality, allowing for simple, convenient, single user workstation output. PCL 2 Adds "EDP (Electronic Data Processing)/Transaction" capabilities, i.e. general purpose, multi-user system printing tools, to the base features provided by PCL 1. PCL 3 Adds "Office Word Processing" functionality -high-quality, office document production - to PCL 2. PCL 4 Adds new Page Formatting functions to PCL 3. The HP LaserJet Series II, for example, supports PCL 4. PCL 5 Adds "Office Publishing" functionality, including font scaling and HP-GL/2 graphics support, to PCL 4. Each level builds upon the previous level, providing backwards and forwards compatibility. For example, any application written for PCL 1 will function with PCL 5 (although the additional features offered by PCL 5 will not be accessed). Likewise, a PCL 4 printer can understand the instructions issued by a PCL 1 application. What are Printer Commands? ========================== PCL language printer commands provide access to printer features. There are three general types of PCL language commands: Control Codes: A control code is a character that initiates a printer function, for example Carriage Return (CR), Line Feed (LF), Form Feed (FF), etc. PCL Commands: PCL commands provide access to the printer's PCL control structure, which controls all printer features (except those used for vector graphics, which is controlled by HP-GL/2 commands). PCL printer commands consist of two or more characters. The first character is always the ASCII escape character (identified here by ). is a special control code which tells the printer that subsequent characters form a printer command, rather than text. As the printer monitors incoming data from a computer, it watches for the character. When this character appears, the printer reads it, and the following associated characters, as a command to be performed. PCL printer commands are also called "escape sequences." Once a PCL command sets a parameter, that parameter will remain set until the PCL command is repeated with a new value, altered by a different command or the printer is reset to default. For example, if you send the printer a command to set line spacing to three lines per inch, each page will print three lines per inch until the printer receives a different line spacing command or is reset. HP-GL/2 (Hewlett-Packard Graphics Language) commands are vector graphics language commands. They are represented in documentation and printer commands as two-letter codes, mnemonically designed to remind you of the function name (for example, IN for initialize). The code may be followed by one or more parameters which identify how the command should be implemented. PCL Hierarchy ============= When escape sequences are sent to the printer, it is important they be sent in the proper order, or hierarchy. The printer commands are grouped according to their significance in the printer command section of the user's manual for each printer. 1. Job Control commands are usually grouped together and sent at the beginning of a job. They should not be sent again until after the job has printed. 2. Page Control commands provide selection of the page source, size, orientation, margins and text spacing. 3. Cursor Positioning commands allow the user to position the printer's "cursor" anywhere within the logical page. 4. Font Selection commands are used to access internal, cartridge and softfonts. Font attributes should be addressed in the order of their significance (i.e. primary spacing before stroke weight). 5. Font Management commands provide mechanisms for downloading and manipulating soft fonts. 6. Graphics commands provide the ability to build dot-per-bit raster images and to fill or shade rectangular areas with a pre-defined pattern. 7. Print Model features allow images and characters to be filled with a pre-defined pattern. 8. Macro commands can be used when tasks need to be performed repeatedly. Macro functionality reduces the number of commands that must be sent to the printer. A macro is a collection of escape sequences, control codes and data downloaded to the printer, whose execution can be initiated using a single command. Syntax of Escape Sequences ========================== There are two forms of PCL escape sequences: two-character escape sequences and parameterized escape sequences. Two-Character Escape Sequences ------------------------------ Two-character escape sequences have the following form: X where "X" is a character that defines the operation to be performed. "X" may be any character from the ASCII table with the 48-126 decimal range. Here are some examples of two-character escape sequences: E an escape sequence that resets the printer 9 an escape sequence that resets the left and right margins of printer output Parameterized Escape Sequences ------------------------------ Parameterized escape sequences have the following form: X y # z1 # z2 # Zn The characters in this string represent the following: X Parameterized Character (from the ASCII table within the 33-47 decimal range) which tells the printer the escape sequence is parameterized. Y Group character (from the ASCII table within the 96-126 decimal range) which tells the printer the type of control code to be performed. # Value field (from the ASCII table within the 48-57 decimal range) which specifies a numeric value. It may be preceded by a "+" or a "-" and may contain fractional values (indicated by a decimal point). The numeric value may be between -32767 and 32767. If the escape sequences requires a value but none is sent, the printer assumes a setting of zero. zi (Z1,Z2, etc.) Parameter character (from the ASCII table within the 96-126 range) which specifies the parameter for the value noted above (#). This character is used when combining, or concatinating, sequences. zn Termination character (from the ASCII table within the 64-94 range) which specifies the parameter for the previous value, and notifies the printer that the escape sequence is finished. Here's an example of a parameterized escape sequence. This one has a termination character (zn above), and no parameter character (zi above); it performs a single function. The example sequence used instructs the printer to output in landscape orientation. ---> parameterized character | | |---> value field & l 1 O | | |---> termination character. | | | ---> group character Escape character Following is an example of an escape sequence with a parameter character and a termination character. This escape sequence performs two functions, combining the commands in (sequence #1) & l 1 O with (sequence #2) & l 2 A: ---> parameterized character | | |---> value field | | | | |---> value field | | | & l 1 o 2 A | | | |---> termination character | | | | | |---> parameter character | | | |---> group character | Escape character When the two sequences are combined, the "" and the "&" "l" are dropped. Also, the "O" that was used as a termination character for the first sequence becomes a lower-case "o" parameter character. Short Form Escape Sequences --------------------------- Parameterized escape sequences can be combined, or concatinated, as in the above example, using these rules: 1. The first two characters after (the parameterized and group characters) must be the same in all the commands that will be combined. In the example used above, the first two characters, "&" and "l" are shared by both sequence #1 and sequence #2. 2. All alphabetic characters within the printer command must be lower- case, with the exception being the always upper-case termination character. In the example above, the "O" of sequence #1 becomes "o"; the final character ("A") is in upper-case. The final character must always be in upper-case, to indicate to the printer that the escape sequence is complete. 3. The printer commands are sent (left to right) in the order they are to be performed. It is important to become familiar with combining escape sequences. Many software packages allow only limited space to input printer commands. For more information about PCL and escape sequences, consult the HP PCL 5 Printer Language Technical Reference Manual, p/n 33459-90903.