ZPLToolkit

^GF

Graphic FieldPreview: partial

Embeds a bitmap directly in the label — the command every PDF-to-ZPL and image-to-ZPL conversion produces.

Syntax

^GFa,b,c,d,data

Parameters

ParameterDescription and accepted valuesIf omitted
aData format. A is ASCII hex; B and C are binary and compressed binary.A ASCII hex, B binary, C compressed binaryA
bNumber of bytes in the data that follows.1 to 99999 — bytes in the data fieldValue of c
cTotal bytes in the graphic.1 to 99999 — total bytes in the graphicValue of b
dBytes per row — eight dots of image width per byte.1 to 99999 — bytes per rowValue of c
dataThe bitmap payload, in the format selected by the first parameter.The bitmap itself, one bit per dotNone

How it works

^GF carries a monochrome bitmap inside the format itself, one bit per dot. It is what a converter emits when it turns a logo or a rendered page into ZPL, and it is the reason converted labels are large: a 4 × 6 inch label at 300 dpi is roughly 700 KB as uncompressed ASCII hex.

The bytes-per-row parameter sets the image width — eight dots per byte, so a 16-dot-wide image is 2 bytes per row. The total byte count divided by bytes per row gives the height. Getting either wrong shears the image diagonally, which is the classic symptom of a bad ^GF.

Format A is ASCII hex and is the most portable. Formats B and C send binary and compressed binary, and Zebra also accepts Z64, a deflate-compressed base64 payload that cuts the size dramatically and is what you want for anything large going over a slow link.

Example

ZPL
^XA
^FO40,40^GFA,32,32,2,FFFFC003A0059009881184218241818181818241842188119009A005C003FFFF^FS
^XZ

Rendering…

A 16 × 16 dot bitmap sent as ASCII hex, two bytes per row.
Open in the viewer

How the preview on this site handles it

ASCII hex is drawn correctly. The format parameter is not yet read, so binary, compressed binary and Z64 payloads do not preview — the field is drawn as if the data were plain hex.

Common mistakes

  • A bytes-per-row value that does not match the image width. The picture comes out sheared.
  • Widths that are not a multiple of 8. The row is padded to the next whole byte, so plan the image around it.
  • Sending large uncompressed hex over a serial link. Use Z64, or store the image once with ~DG and recall it with ^XG.

See also