zpl.tools
Graphics and images

^GD - Graphic Diagonal Line

Draws a diagonal line across a bounding box.

^GD draws a single diagonal line. It takes a bounding box and not two endpoints, and draws the line corner to corner across that box. o selects which pair of corners. It is the only ZPL command that draws a shape other than an axis-aligned one, so crossed-out fields and "void" marks come from it.

Syntax

^GDw,h,t,c,o

Support

Supportedparsed: full · state: full · rendered: full

Every documented parameter renders the same output Labelary produces.

Labelary renders this command.

Parameters

wBox widthoptional · dots

Width of the box the line crosses.

Default
the value of t
Accepted range
3 to 32000 dots
Invalid value
clamped to the nearest allowed value. The renderer clamps widths below 3 to 3.
Test coverage
Bounds pinned: above the maximum (32001). No test at the minimum or maximum. The invalid-value rule is pinned by 3 tests.
hBox heightoptional · dots

Height of the box the line crosses.

Default
the value of t
Accepted range
3 to 32000 dots
Invalid value
clamped to the nearest allowed value. The renderer clamps heights below 3 to 3.
Test coverage
Bounds pinned: above the maximum (32001). No test at the minimum or maximum. The invalid-value rule is pinned by 2 tests.
tBorder thicknessoptional · dots

Thickness of the line, measured perpendicular to it.

Default
1
Accepted range
1 to 32000 dots
Invalid value
clamped to the nearest allowed value
Test coverage
Bounds pinned: above the maximum (32001), past what the shape can hold (300). No test at the minimum or maximum. The invalid-value rule is pinned by 2 tests.
cLine colouroptional · one of a set

Color of the line.

Default
B
Invalid value
discarded, and the default applies. Any value other than B or W draws black.
Test coverage
Values exercised: W. Not exercised: B. The invalid-value rule is not pinned by a test.
B
Black (default)
W
White, which erases what the line covers
oOrientationoptional · one of a set

Which way the diagonal leans. Only L reliably selects the left-leaning direction.

Default
R
Invalid value
discarded, and the default applies. Any other value draws the right-leaning diagonal.
Test coverage
Values exercised: R, L, \. Not exercised: /. The invalid-value rule is pinned by 2 tests.
R
Right-leaning diagonal, bottom-left to top-right (the / direction) (default)
/
Same as R
L
Left-leaning diagonal, top-left to bottom-right (the \ direction)
\
The ZPL II guide writes this as a synonym for L; Labelary's reference omits it. It does not lean left: a backslash draws the default right-leaning diagonal. We measured this on 2026-07-29 — not honoured by zpl.tools

Behavior

The preceding ^FO or ^FT positions the box, and ^FS ends it, exactly as for

^GB. ^FO places the top-left corner. Nothing draws the box itself: it only fixes where the two ends of the line land. To cross out a region, give ^GD the same origin, width and height as the ^GB that outlines it.

The thickness measures across the line. The line runs at an angle, so the renderer cuts its ends square to the box and not perpendicular to the line.

Only R and L work. The ZPL II guide writes the accepted values as R (or /) and L (or \). No other reference carries those two extra spellings, and Labelary's own documentation lists R and L only. The backslash does nothing: ^GD with o set to \ draws the same right-leaning line as the default. The renderer does the same, so a migration changes nothing here, and both engines differ from the guide. Write L.

An unrecognized orientation defaults to R, so a typo here is invisible: the line still draws, and leans the wrong way.

Tested behavior

Differences from the specification

Labelary against the ZPL II guide

Where Labelary — our compatibility target — behaves differently from the printed specification.

  • The ZPL II guide (45541L-004, page 158) writes the accepted values as R (or /) and L (or \). Labelary's reference lists only R and L, and the backslash does not work: ^GD150,150,4,B,\ draws the right-leaning diagonal. We measured this on 2026-07-29. Nothing shows whether Labelary recognizes /, because an unrecognized value also defaults to R. — not pinned by a test

zpl.tools against the ZPL II guide

Where our renderer behaves differently from the specification.

  • As with Labelary, only L selects the left-leaning diagonal; a \ takes the default. The renderer matches Labelary here, so a migration changes nothing. Both differ from the guide. — pinned by the_guides_backslash_synonym_does_not_lean_left

Example

A box with both diagonals drawn across it, forming a cross-out, plus a standalone left-leaning line:

^XA
^FO50,50^GB200,150,2^FS
^FO50,50^GD200,150,2,B,R^FS
^FO50,50^GD200,150,2,B,L^FS
^FO350,50^GD150,150,6,B,L^FS
^XZ

Open in viewer