Kaizen
Browse modulesPeripheralsperipherals/sharedFunctions

Function: encodePrintDataForDevice()

function encodePrintDataForDevice(device: 
  | Pick<{
  connection:   | {
     kind: "webusb";
     usbProductId: number;
     usbSerialNumber?: string | null;
     usbVendorId: number;
   }
     | {
     host: string;
     kind: "network";
     port: number;
   }
     | {
     kind: "qz";
     printerName: string;
   };
  deviceType: "receipt_printer" | "cash_drawer" | "barcode_scanner";
  drawerPin?: 2 | 5 | null;
  id: string;
  make?: string | null;
  metadata?: Record<string, unknown> | null;
  model?: string | null;
  name: string;
  organizationId: string;
  paperWidthChars?: 32 | 35 | 42 | 44 | 48 | null;
  printerLanguage?: "esc-pos" | "star-prnt" | "star-line" | null;
  stationId?: string | null;
  status: "active" | "inactive";
  storeId?: string | null;
}, "printerLanguage" | "paperWidthChars">
  | null
  | undefined, data: 
  | Uint8Array<ArrayBufferLike>
  | ReceiptDocument): Uint8Array;

Defined in: shared/peripherals/encoder.ts:120

Encode print data with a registry device's language/width defaults applied. The single home for the device→encoder-options policy — usePrinter and PrinterConnectionDialog both delegate here so they can't drift.

Parameters

ParameterType
device| Pick<{ connection: | { kind: "webusb"; usbProductId: number; usbSerialNumber?: string | null; usbVendorId: number; } | { host: string; kind: "network"; port: number; } | { kind: "qz"; printerName: string; }; deviceType: "receipt_printer" | "cash_drawer" | "barcode_scanner"; drawerPin?: 2 | 5 | null; id: string; make?: string | null; metadata?: Record<string, unknown> | null; model?: string | null; name: string; organizationId: string; paperWidthChars?: 32 | 35 | 42 | 44 | 48 | null; printerLanguage?: "esc-pos" | "star-prnt" | "star-line" | null; stationId?: string | null; status: "active" | "inactive"; storeId?: string | null; }, "printerLanguage" | "paperWidthChars"> | null | undefined
data| Uint8Array<ArrayBufferLike> | ReceiptDocument

Returns

Uint8Array

On this page