Methods

labelmake({template, input, font})

Source code

Function to create PDF. Works on Node and the browser.

Parameters:
NameTypeDescription
templateTemplateData

Fixed area data and variable area data schema for PDF.

input{ [key: string]: string }[]

Key, value objects corresponding to variable area data schema defined in template. and elements of array correspond to page.

font{ [key: string]: string }optional

Key is corresponding to fontName defined in template. value is base64 encoded data of font file (ttf). Default is roboto.

Returns:

Promise<Buffer> Promise object represents the buffer of PDF.

Types

TemplateData

Source code

Fixed area data and variable area data schema for PDF.

Properties:
NameTypeDescription
schemaTemplateSchema

Variable area data.

backgroundstring | null

Fixed area data.(Supports SVG and Base64 encoded JPEG, PNG)

pageSize{ width: number; height: number; }

Unit is millimeter. For example, A4 size is 210mm x 297mm, → { width: 210, height: 297 }

fontNamestringoptional

Font object key in labelmake function parameter. Default is roboto.

TemplateSchema

Source code

Variable area data schema for TemplateData.

Properties:
NameTypeDescription
typestring

Allow the following strings "text", "image" , "svg", "qrcode", "japanpost", "ean13", "ean8", "code39", "code128", "nw7", "itf14" (Please omit barcode checksum and image is a JPEG, PNG Base64 encoded character string)

widthnumber

Width of variable area.

position{ x: number; y: number; }

Position of variable area.

alignmentstringoptional

Used when type is "text". Allow the following strings "left", "right", "center". Default is left.

fontNamestringoptional

Used when type is "text". Font object key in labelmake function parameter. Default is TemplateData's fontName .

fontSizenumberoptional

Used when type is "text". Default is 12.

characterSpacingnumberoptional

Used when type is "text". Default is 0.

lineHeightnumberoptional

Used when type is "text". Default is 1.