ZPLToolkit

^GB

Graphic BoxPreview: partial

Draws a box or a line. With thickness equal to the height it becomes a solid bar — the basis of every reversed header.

Syntax

^GBw,h,t,c,r

Parameters

ParameterDescription and accepted valuesIf omitted
wBox width in dots.Thickness to 32000 dotsValue of t
hBox height in dots.Thickness to 32000 dotsValue of t
tBorder thickness in dots. Equal to the height, the box becomes solid.1 to 32000 dots1 dot
cLine colour.B black or W whiteB
rCorner rounding, from square to fully rounded.0 to 8 — corner rounding0

How it works

^GB draws a rectangle. The width and height are the outer dimensions and the thickness is the border. A thickness equal to the height collapses the rectangle into a solid filled bar, which is how horizontal rules and reversed header blocks are made.

Because a line is just a very thin box, ^GB covers the separators that divide a shipping label into sections: ^GB700,3,3 is a 700-dot horizontal rule, and swapping the arguments gives a vertical one.

The colour parameter draws in white instead of black, which only makes sense on top of something already black. Corner rounding softens the corners on a scale of 0 to 8.

Example

ZPL
^XA
^FO40,40^GB520,120,4^FS
^FO70,80^A0N,40,40^FDBoxed^FS
^XZ

Rendering…

A 4-dot border with a text field placed inside it.
Open in the viewer

How the preview on this site handles it

Position, dimensions, thickness and colour are drawn. Corner rounding is ignored, so rounded boxes preview with square corners.

Common mistakes

  • Expecting ^GB to fill the box. It draws a border — set the thickness to the height for a solid bar.
  • A thickness larger than the box, which the printer clamps rather than reporting.
  • White boxes on blank stock. They print nothing, since the media is already white.

See also