- A secure browser context (
httpsorlocalhost). - A Chromium-based browser for WebUSB/WebBluetooth support.
- A Brother-compatible device supported by your chosen backend.
npm install
PORT=3000 npm startOpen:
http://localhost:3000/examples/complex_label_with_frontend/
import { BoxItem, Job, Label, Media, P700, Resolution, TextItem, WebUSBBackend } from 'labelprinterkit'
const backend = await WebUSBBackend.requestDevice({ filters: [{ classCode: 7 }] })
const media = Media.W12
const resolution = Resolution.LOW
const rowAHeight = Math.floor(media.printArea * 0.58)
const rowBHeight = media.printArea - rowAHeight
const rowA = new BoxItem(rowAHeight, [new TextItem(rowAHeight, 'First line', '28px sans-serif')])
const rowB = new BoxItem(rowBHeight, [new TextItem(rowBHeight, 'Second line', '22px sans-serif')])
const label = new Label(resolution, rowA, rowB)
const job = new Job(media, { resolution })
job.addPage(label)
const printer = new P700(backend)
await printer.print(job)- The page width must match
media.printAreaorjob.addPage(...)throws. - The page resolution must match job resolution or
job.addPage(...)throws. - The loaded cassette must match the job media; printer status checks run before and after print.
If media/status is wrong (for example, 24mm loaded but 9mm requested), printer.print(...) throws a user-facing error message.
import { getLibraryVersion } from 'labelprinterkit'
console.log(getLibraryVersion()) // "1.0.15"