Methods

labelmake({template, inputs, font})

Source code

Function to create PDF. Works on Node and Browser.

Parameters:
NameTypeDescription
templateTemplate

Base PDF data and variable area data schema for PDF.

inputs{ [key: string]: string }[]

Key, value objects corresponding to variable area data schema defined in template. and elements of array correspond to page. (if input type is barcode or image, then please omit barcode's checksum and image is a JPEG, PNG Base64 encoded character string)

font{ [key: string]: string | Uint8Array | ArrayBuffer }optional

Key is corresponding to fontName defined in template or template's schema. value is data of font file (ttf). Default is Helvetica font.

Returns:

Promise<Uint8Array> Promise object represents the uint8Array of PDF.

Types

Template

Source code

Base PDF data and variable area data schema for PDF.

Properties:
NameTypeDescription
basePdfstring | Uint8Array | ArrayBuffer | { height: number; width: number; }

Fixed area PDF data. *In the case of a string, it is a base64 encoded string. *Height and width are specified in mm

schemas{ [key: string]: TemplateSchema }[]

Variable area data. The key corresponds to the key in inputs and elements of array correspond to page.

fontNamestringoptional

Font object key in labelmake function parameter. Default is Helvetica font.

TemplateSchema

Source code

Variable area data schema for Template.

Properties:
NameTypeDescription
type"text" | "image" | "qrcode" | "japanpost" | "ean8" | "ean13" | "code39" | "code128" | "nw7" | "itf14" | "upca" | "upce"

Input Type of variable area. Text, images and various barcodes are available.

widthnumber

Width of variable area. (Unit is mm)

heightnumber

Height of variable area. (Unit is mm)

position{ x: number; y: number; }

Position of variable area. (Unit is mm)

rotatenumberoptional

Rotate of variable area. Default is 0.

alignment"left" | "right" | "center"optional

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

fontNamestringoptional

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

fontSizenumberoptional

Used when type is "text". Default is 13.(Unit is pt)

fontColorstringoptional

Used when type is "text". Default is #000.

backgroundColorstringoptional

Used when type is "text". Default is #000.

characterSpacingnumberoptional

Used when type is "text". Default is 0.(Unit is pt)

lineHeightnumberoptional

Used when type is "text". Default is 1. (Unit is em)