API Schema Reference
The canonical API route is POST /api/v1/label.
The request body is a single DocumentRequest JSON object.
Root: DocumentRequest
| Field | Type | Required |
|---|---|---|
settings | Settings | No |
pages | Page[] | Yes |
header | Section | No |
footer | Section | No |
Page Sizing
Each page must define its physical size in exactly one of these ways:
- Explicit millimeters:
width+height - Preset size:
size
Rules:
sizeandwidth/heightare mutually exclusivewidthandheightmust be provided together- Preset matching is case-insensitive
Supported preset values:
a4a6letterlegallabel_100_100label_100_150label_4_6_in
Section (header / footer)
header and footer share the same shape:
height: numberin mmelements: Element[]
Behavior:
headeris repeated on every pagefooteris repeated on every pageheaderelements render in absolute page coordinatesfooterelements render with a bottom offset ofpage.height - footer.heightfooter.heightreduces the available body height for paginationheaderdoes not automatically push body elements down- optional
settings.page_margin/pages[].margindefine a body content box - when page margins are configured, body
x/ybecome relative to the content box - body elements outside the content box fail validation
Settings
| Field | Type |
|---|---|
defaults | Defaults |
metadata | Metadata |
output | OutputSettings |
profile | string |
page_margin | PageMargin |
Defaults uses unified style objects:
text: TextStylestroke: StrokeStylefill: FillStyleshape: ShapeDefaults
OutputSettings
mode:binaryorfilefile_name: optional custom file name used whenmode = "file"- default behavior is
binary - missing
file_namefalls back togPdf-MMDDHHmmssSSS.pdf
Element Types
elements[] is a tagged union by type:
textbarcodelinerectcircleellipsepolygonlinkimagetablestack
Image payloads currently support:
- Raster:
jpg/jpeg/png/webp - Vector image payloads:
svg
stack
- body-only flow element for
tablefollowed by one or moreblocks children[0]must betable- later children must be
block gapis the vertical distance between the table's final bottom and the next block's start
block
- follow-up content group used inside
stack - no own
x/y/width/height - child
xkeeps current body semantics - child
yis relative to the block start - cannot nest
table/stack/block
x_anchor
- supported by
text,barcode,rect,image, andlink - mutually exclusive with
x - supports
page_*andcontent_*references everywhere - supports
table_left/table_rightonly insidestack -> block textrequiresstyle.widthwhenx_anchoris used
Unified Vector Styling
Vector elements use the same schema:
stroke: StrokeStylefill: FillStyle
This is shared by line / rect / circle / ellipse / polygon. Table borders also use the same StrokeStyle model for grid.frame, grid.horizontal, grid.vertical, and cell.borders.
StrokeStyle includes optional compound for compound strokes. The currently supported kind is double.
Hyperlink Model
- Attached links:
text/barcode/line/rect/circle/ellipse/polygon/imagesupport optionallink: LinkSpec - Independent hotspots:
type: "link"supports area-based click targets without visible graphics LinkSpec.targetsupports:- URL:
{ "type": "url", "url": "https://..." } - Page destination:
{ "type": "page", "page": 2, "x": 10, "y": 20 }
- URL:
- URL schemes are restricted to
http,https,mailto,tel - Invalid link fields fail validation instead of being silently ignored
Table Schema
The only supported public table schema is centered on:
columnsrowscellheaderrow_headerbodygridpagination
Key rules:
- row headers are modeled as
columns[].role = "row_header" grid.frame,grid.horizontal, andgrid.verticalacceptStrokeStylecolumns[].widthis always a width object:fixed,percent, orautopercentandautorequiretable.width- grouped headers live in
header.rows; leaf headers still usecolumns[].header TableCellStylesupportscontent_offset_x/content_offset_y- row objects may only contain keys declared in
columns[].key - legacy lightweight payloads such as
data/layout/theme/row_headers/corner/style_overridesare no longer part of the public API
Notes
- Deprecated payloads (
LabelRequest[],pdf_params,items,1d_params,2d_params) are not part of the current public schema. - Runtime defaults are distributed through
GET /v1/xpdf/runtime-config; worker and server use the same runtime source of truth. - See JSON 数据结构 for complete field-level details.