Skip to content

API Reference (Gemini Edition)

API Endpoint: POST /api/v3/labelFormat: JSON Auth: Bearer Token

This reference documentation details the data structures used to generate PDFs with xPdf.

🧭 Request Structure

The API accepts a List of LabelRequest objects. This allows for batch generation of multiple PDFs in a single HTTP call.

json
[
  { "Request 1" },
  { "Request 2" }
]

🏗️ Core Objects

1. LabelRequest

The root object for a single PDF generation task.

FieldTypeRequiredDescription
tracking_numberStringNoUnique identifier for tracking this request in logs.
pdf_paramsPdfParamsNoGlobal settings for the PDF (size, metadata, profile).
itemsList<Item>YesThe content layers (text, barcodes, images) to draw.

2. PdfParams (Document Settings)

Controls the output file properties and PDF metadata.

FieldTypeDefaultDescription
Page Layout
widthFloat100.0Page width in millimeters (mm).
heightFloat150.0Page height in millimeters (mm).
Output Control
save_fileBoolfalseIf true, saves the generated PDF to the server's disk.
output_dirString-Directory path for saved files (if save_file is true).
file_nameString-Filename for the saved PDF.
global_fontString-Default font family for the document.
PDF/A Compliance
pdf_profileString""See Supported Profiles.
Metadata
metadata_titleString-Required for PDF/UA-1. Title of the document.
metadata_languageStringAutoISO 639-1 code (e.g., en, zh). Auto-detected if missing.
metadata_authorsString-Author name(s).
metadata_subjectString-Subject or keywords.

Supported PDF Profiles

ValueStandardUse Case
"" (Empty)Standard PDFGeneral purpose, smallest size.
pdfa-1bPDF/A-1bBasic archiving.
pdfa-ua1PDF/UA-1Accessibility (Strict). Requires metadata_title.

3. Item (Content Layer)

A grouping of visual elements. All fields are optional lists.

FieldJSON KeyTypeDescription
one_d_params1d_paramsList<OneDParams>Linear barcodes (Code128, EAN).
two_d_params2d_paramsList<TwoDParams>Matrix codes (QR, DataMatrix).
text_elementstext_elementsList<TextElement>Absolute text labels.
lineslinesList<Line>Vector lines.
rectanglesrectanglesList<Rectangle>Shapes and borders.
imagesimagesList<ImageElement>Bitmaps (JPG, PNG).

🎨 Visual Elements

4. OneDParams (Linear Barcodes)

Standard linear barcodes like logistics labels.

FieldTypeUnitDescription
1d_contentString-(Required) The data to encode.
formatString-Code128, Code39, EAN13, UPCA, ITF, Codabar.
positionPositionmm{ "x": 10, "y": 10 } origin point.
sizeBarcodeSizemm{ "height": 15, "module_width": 0.3 }.
human_readable_textHumanReadableText-Text shown near the barcode.
orientationIntdegRotation: 0, 90, 180, 270.
quiet_zoneIntmodsSafe margin around barcode (default: 10).

5. TwoDParams (Matrix Codes)

2D codes like QR Codes.

FieldJSON KeyTypeDescription
two_d_content2d_contentString(Required) The data/URL to encode.
formatformatStringQRCode, DataMatrix, PDF417, Aztec.
module_sizemodule_sizeFloatPixel size in mm (e.g., 0.5).
xxFloatX coordinate (mm).
yyFloatY coordinate (mm).

6. TextElement

Independent text labels.

FieldTypeDescription
contentStringText string to display.
x, yFloatcoordinates (mm).
font_sizeFloatSize in points (pt).
font_nameStringFont family (must be loaded).
boldBooltrue for bold weight.
alignStringLeft, Center, Right.
colorStringHex color (e.g., #FF0000).

7. Line

Vector lines.

FieldTypeDescription
x1, y1FloatStart point (mm).
x2, y2FloatEnd point (mm).
thicknessFloatLine width (mm).
colorStringStroke color (Hex).

8. Rectangle

Boxes and borders.

FieldTypeDescription
x, yFloatTop-left corner (mm).
width, heightFloatDimensions (mm).
thicknessFloatBorder width (mm).
radiusFloatCorner radius (mm).
fillBooltrue to fill, false for stroke only.
colorStringColor (Hex).

9. ImageElement

Raster images.

FieldTypeDescription
x, yFloatPosition (mm).
width, heightFloatDisplay size (mm).
base64StringPriority 1: Raw image data.
image_pathStringPriority 2: Local server path.
image_nameStringPriority 3: Pre-loaded asset name.

🧩 Helper Types

10. Helper Types

Position

json
{ "x": 10.0, "y": 20.0 }

BarcodeSize

json
{
  "height": 15.0,        // Bar height
  "module_width": 0.3,   // Width of narrowest bar
  "width": 50.0          // Optional total width override
}

11. HumanReadableText

Attached to 1D Barcodes.

FieldTypeDescription
enabledBoolShow text?
contentStringOverride text (defaults to barcode data).
sideInt0 = Bottom, 1 = Top.
alignStringCenter, Left, Right.

⚠️ Error Codes

CodeMeaningSolution
E002Invalid Profilepdf_profile must be one of the supported strings or empty.
E003Missing MetadataFor pdfa-ua1, metadata_title is required.

Generated by Gemini - 2026-01-03