jesusbmx / react-native-zpl-code

This TypeScript library provides a builder pattern for generating Zebra Programming Language (ZPL) commands for label printing. It is designed to simplify the creation of ZPL commands for various elements such as text, barcodes, QR codes, rectangles, and images.
MIT License
4 stars 1 forks source link

Image command not working in printer #1

Open ajayvraikar opened 7 months ago

ajayvraikar commented 7 months ago

I generated zpl image command using this library. But its working in Zpl previewer But in actual printer it's not working. Please look into this.

jesusbmx commented 6 months ago

I generated zpl image command using this library. But its working in Zpl previewer But in actual printer it's not working. Please look into this.

Hello, how are you? At the moment, the library only generates ZPL code. I am planning to implement the print function. You can use another library like react-native-tcp-socket

import TcpSocket from 'react-native-tcp-socket';
import { Zpl } from "react-native-zpl-code";

// Create socket
const options = {
  port: 9100,
  host: '192.168.0.1', // printer
  reuseAddress: true,
};

const client = TcpSocket.createConnection(options, async () => {
  // Create a ZPL builder instance
  const zplBuilder = new Zpl.Builder();
  ...
  // Generate ZPL code
  const zplCode = await zplBuilder.build();

  // Write on the socket
  client.write(zplCode);

  // Close socket
  client.destroy();
});