i have zebra printer and connect to this by webUsb and command to print by tsplCommand But the printer output prints in black stripes. how can i fix that
const devices = await navigator.usb.getDevices();
const printer = devices.find(
(item: any) => item.manufacturerName === "IDPrinter",
);
const device = await navigator.usb.requestDevice({
filters: [
{ vendorId: printer?.vendorId, productId: printer?.productId },
],
});
const imageData = canvas.toDataURL("image/png");
const response = await fetch(imageData);
const blob = await response.blob();
const arrayBuffer = await blob.arrayBuffer();
const byteArray = new Uint8Array(arrayBuffer);
const tsplCommand = `
SIZE 100 mm, 50 mm
GAP 2 mm, 0 mm
DIRECTION 1
CLS
BITMAP 10,10,${canvas.width / 8},${canvas.height},1,${byteArray}
PRINT 1,1
`;
const encoder = new TextEncoder();
const data = encoder.encode(tsplCommand);
await device.open();
await device.selectConfiguration(1);
await device.claimInterface(0);
await printer.transferOut(1, data);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744201772a4562913.html
评论列表(0条)