Design a Reusable Label Template for JSON-to-PDF Output

Bind a label layout to product fields, save it once, and reuse it for new data and copy counts.

G Gookit Team
· · 5 min read

A reusable label template holds the layout; each print request supplies the changing data. Keep dimensions, typography and barcode placement in the template so your integration can generate another batch without rebuilding the design.

For a product label, the useful boundary is concrete: the template knows where name and sku appear, while each record supplies their values.

Start from the label stock

Choose physical width and height before positioning elements. The supplied template is a nominal 50 × 30 mm ROLL label, producing one label per PDF page. It contains a product name, Code 128 barcode and readable SKU.

Open the Label Editor under the same developer account that owns the API key, or create the template through the API using the downloadable JSON. Templates belong to an account: a merchant key and an independent developer key should not be treated as interchangeable.

Bind each element to a field or a fixed value

An element uses either field for record data or value for fixed content. Set one, not both.

{"type":"text","x":3,"y":2,"width":44,"height":5,"field":"name","fontSize":10}

This element reads data.name. A static heading would instead use value: "WAREHOUSE COPY" and omit field.

Design decisionExampleWhat changes between records
Product nameText bound to nameDisplayed name
BarcodeCode 128 bound to skuEncoded SKU
Readable identifierText bound to skuSame SKU printed as text
Fixed wordingText with valueNothing

Keep field names consistent across layouts. If a second label also accepts name and sku, the same mapped data can use it after you change the template ID.

Save the layout and retain its ID

Create it with POST /templates using your developer key. The batch tutorial shows the complete curl command and how to extract the returned id. Store that ID in the integration that chooses the layout, then reference it as templateId in print requests.

Save once and reuse it for subsequent batches. If you edit the same saved template, later jobs can use the changed layout; retain your own versioned template snapshot when historical reproduction matters.

The API’s public paper presets provide dimensions and layout settings, not proof that every preset is ready for a specific printer. Inspect geometry and validation errors before adopting a preset.

Preview with representative values

Use a short name, a long name and a SKU with leading zeros. A single short demo name will not reveal how a narrow text box handles real inventory descriptions.

A PNG preview is useful for one record. The preview endpoint is POST /render with an inline template and sample data; production PNG output uses account allowance too. To validate quantities and pagination, generate a small PDF batch as well.

Check text clipping, whitespace around codes, rotation, label size and the decoded barcode value. Increasing the visual size of a label image in a web page does not change the PDF’s physical dimensions.

Reuse the template for the next task

A lot label may need lot and a bin label may need bin. Add those bindings deliberately and update the caller’s data contract. Do not expect arbitrary ERP fields to appear just because they exist in the request.

Gookit’s template format is intended for label output. If your document needs flowing paragraphs, repeating invoice tables or a complete form-filling workflow, evaluate a document-oriented tool against that task before choosing a label template API.