ZPL Direct Print with Deno (Raw ZPL Code)
Chris Brocklesby
This is a simple Deno script to print a ZPL code directly to a Zebra printer using Deno JS Runtime.
import net from "https://deno.land/std@0.152.0/node/net.ts";
const HOST = "192.168.1.123"; // Zebra Printer IP
const PORT = 9100;
// Open ZPL Code Template
const zpl = await Deno.readFile("./templates/label.zpl");
const client = net.connect(PORT, HOST, () => {
console.log("Printing labels...");
client.write(zpl);
client.end();
});
client.on("data", (data) => {
console.log(data.toString());
console.log("socket.bytesRead is " + client.bytesRead);
client.end();
});
client.on("end", () => {
console.log("client disconnected");
});