HPGL (Hewlett-Packard Graphics Language)

From Bauman National Library
This page was last modified on 21 May 2016, at 21:54.
Designed by Hewlett-Packard
Filename extensions .hpgl
Website None

HPGL(Hewlett-Packard Graphics Language) - graphic language designed to determine the three-dimensional graphics for the entire range of plotters manufactured by Hewlett-Packard. Hewlett-Packard has found itself in the fortunate position of having creating two de facto standards for output devices: HPGL (short for Hewlett-Packard Graphics Language) and PCL, short for Printer Control Language. Although HPGL was intended for HP's line of pen plotters, variants have found their way into inkjet and laser printers. PCL, on the other hand, is strictly used by HP for its raster devices and is very slowly loosing favor to PostScript and Windows-based direct-GDI.

What HPGL?

HPGL is a command set embedded in the ROM of pen plotters to help reduce the work required by applications programmers to create plotted output. HPGL uses two-letter mnemonics as instructions for drawing lines, circles, text, and simple symbols. HPGL has evolved over the years as HP added features to its line of pen, electrostatic, inkjet, and laser plotters and printers.

However, there is one primary drawback to HPGL: it is bulkier than other plotting languages, which means it takes longer to transmit an HPGL plot file than, say, a Houston Instruments' DM/PL (short for digital microprocessor plotting language) plot file. To overcome the limitation, Hewlett-Packard in 1988 introduced HPGL/2, which featured "polyline encoding," a form of data compression that reduces the plot file size and, hence, transmission time by two-thirds.

With HPGL being the de facto plotting standard, competitors inevitably include HPGL or some similarly-named dialect in their plotter products. In addition, HPGL has become a form of CAD drawing translation of last resort, since all CAD packages produce HPGL files and several read the format.

Coordinate Systems

One irritant to HPGL is that there are two different coordinate systems in use. Small-format plotters, including A- and B-size plotters, locate the origin at the lower-left corner; large-format plotters, including D- and E-size plotters, located the origin at the center of the media.

40 plu = 1 mm

All plotting languages have two forms of limits:

  1. hard limits - the hard limits are the limits beyond which the plotter cannot plot due to physical constraints.
  2. soft limits - The soft limits are usually imposed by the application software generating the plot file.

Any part of the drawing extending beyond the limits (hard or soft) is clipped (is not be plotted).

Reading An HPGL Plot File

A typical HPGL plot file consists mostly of ASCII characters with some control codes thrown in. You can read the file with any text editor. Since the plot files tend to be written as one long line (no CR or LF), it is helpful to have a text editor with no limitation on line length.

When you load a plot file into the text editor, it looks something like this:

Plot initialization data:


Plot data:

PA12345,4567;PD;PA-2345;6789; ...et cetera

Plot termination data:


Decoding the HPGL Code

HPGL consists of two kinds of instructions:

  1. HPGL instructions.
  2. Device-control instructions (or DCI, for short).

The most typical HPGL instruction is:


The PA instruction moves the pen to absolute position (1234,5678) in plu coordinates. The instruction has four parts to its syntax: PA is an HPGL command (in this case, to move the pen).

1234 and 5678 are parameters (in this case, absolute coordinates). "," a separator (the comma) between two or more parameters. ";" and a terminator (the semi-colon).

PA All HPGL instructions start with a two-letter mnemonic. For example, PA is the abbreviation for Pen Absolute, a pen positioning command. Other common command mnemonics include:

  • PD for pen down
  • PU for pen up
  • SP for select pen
  • VS for velocity speed.

1234 and 5678 Most HPGL instructions include one or more parameters to modify their meaning. Here, 1234 and 5678 are the absolute pen coordinates in plu. Parameters of other instructions are the pen number and plotter speed.

Most HPGL instructions include one or more parameters to modify their meaning. To use the default parameter of an instruction, simply leave out the parameter value.

When an instruction uses more than one parameter, HPGL wants them separated with:

  • a comma ( , )
  • a space ( )
  • a plus sign ( + )
  • a negative sign ( - ).

Device-Control Instructions

HPGL uses device-control instructions to set up the plotter's hardware. These instructions set up communications between the CAD software and the plotter, return plotter status data, reset the plotter, et cetera.

Device-control instructions (DCI, for short) begin with the escape character (ASCII 27, or 1B in hex) shown as [Esc] in this tutorial.

A typical HP device-control instruction looks like this:


This statement defines the command to activate the device end instructs the plotter to interpret data as HPGL and DCI instructions, rather than plotting the data stream as literal text characters. This DCI has no parameters.

Escape sequences:
Command Meaning
esc.@ Set Plotter Configuration
esc.A Output Identification
esc.B Output Buffer Space
esc.E Output Extended error
esc.H et Handshake Mode 1
esc.I et Handshake Mode 2
esc.J Abort Device Control
esc.K Abort Graphics
esc.L Output Buffer Size When Empty
esc.M Set Output Mode
esc.N Set Extended Output and Handshake Mode
esc.O Output Extended Status
esc.P Set Handshake Mode
esc.Q Set Monitor Mode
esc.R Reset
esc.S Output Configurable Memory
esc.T Allocate Configurable Memory
esc.U End Flush Mode
esc.Y Plotter On
esc.( Plotter On
esc.Z Plotter Off
esc.) Plotter Off