ZPLToolkit

~DG

Download GraphicPreview: partial

Stores an ASCII-hex bitmap in printer memory under a name, so later labels can recall it with ^XG instead of carrying the whole image.

Syntax

~DGd:o.x,t,w,data

Parameters

ParameterDescription and accepted valuesIf omitted
d:o.xStorage device, graphic name and extension. Omit pieces only when the printer defaults are deliberate.Device, name and .GRF extensionR:UNKNOWN.GRF
tTotal bytes in the bitmap payload.Total bytes in the graphicRequired
wBytes in each bitmap row. The drawn width is eight times this value.Bytes per rowRequired
dataASCII hexadecimal bitmap bytes, in row order.ASCII hexadecimal graphic dataRequired

How it works

~DG downloads one monochrome graphic to a printer device such as volatile R: memory or persistent E: memory. The data is ASCII hexadecimal, with every pair of characters describing one byte of eight horizontal dots.

The byte total and bytes-per-row describe the same bitmap geometry as ^GF: divide the total by bytes per row to find its height, then multiply the row bytes by eight to find the padded width. A mismatch gives a corrupted or rejected stored image.

Downloading is not drawing. A later ^XG field names the stored object and places it on a label; this is useful for a logo shared by many labels, but it also means the printer's memory must contain the expected asset.

Example

ZPL
~DGR:SQUARE.GRF,32,2,FFFFC003A0059009881184218241818181818241842188119009A005C003FFFF
^XA
^FO40,40^XGR:SQUARE.GRF,2,2^FS
^XZ

Rendering…

The bitmap is downloaded before the format, then ^XG recalls it at double size.
Open in the viewer

How the preview on this site handles it

The preview records a ~DG in this same paste and lets ^XG recall it. ~DG itself is recognized but draws nothing; graphics already stored only on a real printer are unavailable here.

Common mistakes

  • Using R: for a logo that must survive a reboot. R: is volatile memory; use the intended persistent device and manage its capacity.
  • Changing the graphic name in ~DG but not in ^XG. The field then resolves to an empty image without a visible printer error.
  • Sending a total-byte count that does not agree with the hex data or bytes per row. Check the bitmap dimensions before putting it in a template.

See also