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.
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.
Markdown · OpenAPI · Postman · llms.txt
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
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
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}'const res = await fetch('https://apibox.io.vn/v1/zpl-render', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"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
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/zpl-render",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"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},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/zpl-render');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"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}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"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.
Related APIs
QR Code Generator
Generate QR codes as PNG or SVG with one GET request: URLs, text, WiFi logins, vCards, e-mail, SMS, phone and geo links. Custom colours, size and ECC.
|||Barcode Generator
Create Code 128 barcodes for labels, SKUs and shipping with a single request. SVG with human-readable text or PNG, custom height, width and colours.
▭Placeholder Image
Get placeholder images of any size for mockups and tests: /v1/placeholder/600x400.png. SVG with custom text and colours, or a solid-colour PNG.