# ZPL Viewer (render ZPL to PNG / PDF) API

> Render Zebra ZPL II label code to PNG or a multi-page PDF at 6 / 8 / 12 / 24 dpmm: text with Vietnamese, boxes, Code 128, EAN-13, Code 39, QR, ^GF images.

- Endpoint: `GET | POST https://apibox.io.vn/v1/zpl-render`
- Category: Images & Codes
- HTML docs: https://apibox.io.vn/docs/zpl-render/ (Vietnamese: https://apibox.io.vn/vi/docs/zpl-render/)
- Online tool: https://apibox.io.vn/tools/zpl-render/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send ZPL (one or many `^XA … ^XZ` labels) with the printer density `dpmm` (6, 8 = 203 dpi default, 12 = 300 dpi, 24) and the label size in inches (`width` 4, `height` 6 by default; `^PW` / `^LL` in the code win when smaller), and get a PNG per label (JSON), one label as PNG (`format=png`, `index`), or all labels as a PDF whose pages have the real label size (`format=pdf`), ready for a laser printer or a PDF viewer.

Supported commands: `^FO` `^FT` `^LH` `^PW` `^LL` `^LR` `^A` / `^CF` (font 0 scalable, bitmap fonts A–H, orientations N / R / I / B) `^FW` `^FB` (wrapping, justification, max lines) `^FD` `^FV` `^FS` `^FH` (hex escapes) `^FR` (reverse) `^GB` (boxes, lines, rounding) `^GC` `^GE` `^GD` `^GF` (ASCII hex, with ZPL compression) `^BY` `^BC` (Code 128) `^B3` (Code 39) `^BE` (EAN-13) `^BQ` (QR) `^CI28` (UTF-8: Vietnamese prints) `^PQ` `^FX`. Unsupported commands are listed in `warnings` (DataMatrix and PDF417 are drawn as placeholders).

Fonts are open substitutes (Be Vietnam Pro for font 0, JetBrains Mono for the bitmap fonts), so text widths differ slightly from a Zebra printer; positions, boxes and barcodes are exact dots. Up to 50 labels per request.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `zpl` | body|query | string | yes |  | ZPL code (or a raw text body / `file`). Max 3 MB, 50 labels. |
| `dpmm` | body|query | number | no | `8` | Printer density: 6, 8, 12 or 24 dots per mm. |
| `width` | body|query | number | no | `4` | Label width in inches. |
| `height` | body|query | number | no | `6` | Label height in inches. |
| `format` | body|query | string | no | `json` | `json` (PNG per label), `png` (one label) or `pdf` (all labels). |
| `index` | body|query | number | no |  | Render only this label (1-based). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/zpl-render" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"zpl":"^XA\n^FO40,40^A0N,40,40^FDXin chào^FS\n^FO40,100^BY2^BCN,80,Y,N,N^FD12345678^FS\n^XZ","width":2,"height":1}'
```

## Example response

```json
{
  "label_count": 1,
  "dpmm": 8,
  "dpi": 203,
  "labels": [
    {
      "index": 1,
      "width": 406,
      "height": 203,
      "fields": 2,
      "copies": 1,
      "png": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZYAAADLCAAAAA…"
    }
  ],
  "warnings": []
}
```

## Use cases

- Preview carrier labels (DHL, FedEx, UPS, GHN) returned as ZPL before printing
- Print ZPL labels on an office laser printer through the PDF output
- Show label previews in a WMS or e-commerce back office
- Test ZPL templates in CI without a physical printer

## FAQ

### Is the output pixel-identical to a Zebra printer?

Boxes, positions and barcodes are; text uses open fonts with similar metrics, so line breaks can differ slightly.

### Does it print Vietnamese?

Yes, with ^CI28 (UTF-8) the text is drawn with a full Vietnamese font. Real printers need a Unicode font loaded for the same result.

### Which barcodes are supported?

Code 128, Code 39, EAN-13 and QR. Other symbologies are reported in warnings and drawn as an empty box.
