Skip to content

Releases

V 2.0.0

Choose a tag to compare

@rmunate rmunate released this 30 Sep 17:52

ZPL Print Universal Driver (Windows)

ZPLPrintDriver.exe is a versatile command-line tool for sending ZPL (Zebra Programming Language) code to network-connected and USB-connected Zebra printers. It is designed for easy integration into various programming environments that support console command execution.

Features

  • Send ZPL code directly from a file to a Zebra printer over the network.
  • Supports specifying the printer's IP address and port.
  • Allows printing multiple copies of the label.
  • Configurable timeout for network operations.
  • Cross-language compatibility through easy-to-use command-line execution.

Usage

You can run the program directly from the command line by providing the necessary arguments.

Command Line Arguments

Print Over Network

  • --path (required): Full path to the ZPL file you want to send to the printer.
  • --printer (required): The IP address of the Zebra printer.
  • --port (optional): Printer port number. Default is 9100.
  • --copies (optional): Number of copies to print. Default is 1.
  • --timeout (optional): Timeout in seconds for the network connection. Default is 10 seconds.
ZPLPrintDriver.exe --path "C:\path\to\your\file.zpl" --printer "192.168.1.100" --port 9100 --copies 2 --timeout 10

Print Over USB

To print using a USB connection, you need to obtain the vendorId and productId from your printer's properties. Use these values in the format USB:vendorId:productId. For example:

  • --path (required): Full path to the ZPL file you want to send to the printer.
  • --usb (required): Indicates that the operation will use USB.
  • --vendor_id (required): Value extracted from the hardware identifier properties.
  • --product_id (required): Value extracted from the hardware identifier properties.

ExtractData

Where to find values: USB\VID_0A5F&PID_0081, vendor_id and product_id, respectively.

ZPLPrintDriver.exe --path="example.zpl" --usb --vendor_id="0A5F" --product_id="0081"

Using from Various Programming Languages

Python Example (Network)

In Python, you can use the subprocess module to call ZPLPrintDriver.exe.

import subprocess

# Command to run the executable with arguments
command = [
    "ZPLPrintDriver.exe",
    "--path", "C:\\path\\to\\your\\file.zpl",
    "--printer", "192.168.1.100",
    "--port", "9100",
    "--copies", "1",
    "--timeout", "10"
]

# Execute the command
result = subprocess.run(command, capture_output=True, text=True)

# Print the output
print(result.stdout)

Python Example (USB)

In Python, you can use the subprocess module to call ZPLPrintDriver.exe.

import subprocess

# Command to run the executable with arguments
command = [
    "ZPLPrintDriver.exe",
    "--path", "C:\\path\\to\\your\\file.zpl",
    "--usb",
    "--vendor_id", "0A5F",
    "--product_id", "0081"
]

# Execute the command
result = subprocess.run(command, capture_output=True, text=True)

# Print the output
print(result.stdout)

C# Example

In C#, you can use the Process class to execute the command and interact with the output.

using System;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        // Create and configure the process
        Process process = new Process();
        process.StartInfo.FileName = "ZPLPrintDriver.exe";
        process.StartInfo.Arguments = "--path \"C:\\path\\to\\your\\file.zpl\" --printer \"192.168.1.100\" --port 9100 --copies 1 --timeout 10";
        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.CreateNoWindow = true;

        // Start the process
        process.Start();

        // Read and display the output
        string output = process.StandardOutput.ReadToEnd();
        Console.WriteLine(output);

        // Wait for the process to exit
        process.WaitForExit();
    }
}

PHP Example

In PHP, the exec() function can be used to invoke the executable.

<?php
// Command to execute the ZPL print driver
$command = "ZPLPrintDriver.exe --path \"C:\\path\\to\\your\\file.zpl\" --printer \"192.168.1.100\" --port 9100 --copies 1 --timeout 10";

// Execute the command and capture the output
$output = shell_exec($command);

// Display the output
echo $output;
?>

Ruby Example

In Ruby, you can use the system() function to run the command.

# Command to run the ZPLPrintDriver.exe
command = 'ZPLPrintDriver.exe --path "C:\\path\\to\\your\\file.zpl" --printer "192.168.1.100" --port 9100 --copies 1 --timeout 10'

# Execute the command
system(command)

Visual Basic (VBScript) Example

In VBScript, you can use the WScript.Shell object to run the executable.

Set objShell = WScript.CreateObject("WScript.Shell")

' Command to run ZPLPrintDriver.exe
command = "ZPLPrintDriver.exe --path ""C:\path\to\your\file.zpl"" --printer ""192.168.1.100"" --port 9100 --copies 1 --timeout 10"

' Execute the command
objShell.Run command, 0, True

PowerShell Example

In PowerShell, you can execute the command using Start-Process.

# Define the command
$command = "ZPLPrintDriver.exe --path 'C:\path\to\your\file.zpl' --printer '192.168.1.100' --port 9100 --copies 1 --timeout 10"

# Execute the command
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $command" -NoNewWindow -Wait

WScript (Windows Script Host) Example

In WScript, you can execute the command with Exec and capture the output.

var shell = new ActiveXObject("WScript.Shell");

// Command to run ZPLPrintDriver.exe
var command = 'ZPLPrintDriver.exe --path "C:\\path\\to\\your\\file.zpl" --printer "192.168.1.100" --port 9100 --copies 1 --timeout 10';

// Execute the command
var exec = shell.Exec(command);

// Read and print the output
while (!exec.StdOut.AtEndOfStream) {
    WScript.Echo(exec.StdOut.ReadLine());
}

JavaScript (Node.js) Example

In Node.js, use the child_process module to run the executable.

const { exec } = require('child_process');

// Command to run the executable
const command = 'ZPLPrintDriver.exe --path "C:\\path\\to\\your\\file.zpl" --printer "192.168.1.100" --port 9100 --copies 1 --timeout 10';

// Execute the command
exec(command, (error, stdout, stderr) => {
    if (error) {
        console.error(`Error: ${error.message}`);
        return;
    }
    if (stderr) {
        console.error(`Stderr: ${stderr}`);
        return;
    }
    console.log(`Stdout: ${stdout}`);
});

Excel VBA Example

In Excel VBA, you can execute the command using the Shell function.

Sub PrintZPL()

    ' Define the command arguments
    Dim zplFile As String
    Dim printerIP As String
    Dim printerPort As String
    Dim copies As Integer
    Dim timeout As Integer
    Dim command As String

    ' Set the values for the ZPL file path, printer IP, port, and other parameters
    zplFile = "C:\path\to\your\file.zpl"
    printerIP = "192.168.1.100"
    printerPort = "9100"
    copies = 1
    timeout = 10

    ' Create the full command string
    command = "ZPLPrintDriver.exe --path """ & zplFile & """ --printer """ & printerIP & """ --port " & printerPort & " --copies " & copies & " --timeout " & timeout

    ' Execute the command using the Shell function
    Shell command, vbNormalFocus

End Sub

F# Example

In F#, you can use the System.Diagnostics.Process class to execute the command similarly to C#.

open System.Diagnostics

let command = "ZPLPrintDriver.exe --path \"C:\\path\\to\\your\\file.zpl\" --printer \"192.168.1.100\" --port 9100 --copies 1 --timeout 10"

let process = new Process()
process.StartInfo.FileName <- "cmd.exe"
process.StartInfo.Arguments <- sprintf "/c %s" command
process.StartInfo.RedirectStandardOutput <- true
process.StartInfo.UseShellExecute <- false
process.StartInfo.CreateNoWindow <- true

process.Start() |> ignore
let output = process.StandardOutput.ReadToEnd()
printfn "%s" output
process.WaitForExit()

Rust Example

In Rust, you can use the std::process::Command module to execute the command.

use std::process::Command;

fn main() {
    let output = Command::new("ZPLPrintDriver.exe")
        .arg("--path")
        .arg("C:\\path\\to\\your\\file.zpl")
        .arg("--printer")
        .arg("192.168.1.100")
        .arg("--port")
        .arg("9100")
        .arg("--copies")
        .arg("1")
        .arg("--timeout")
        .arg("10")
        .output()
        .expect("Failed to execute process");

    println!("{}", String::from_utf8_lossy(&output.stdout));
}

Go Example

In Go, you can use the os/exec package to call the executable.

package main

import (
	"fmt"
	"os/exec"
)

func main() {
	cmd := exec.Command("ZPLPrintDriver.exe", "--path", "C:\\path\\to\\your\\file.zpl", "--printer", "192.168.1.100", "--port", "9100", "--copies", "1", "--timeout", "10")

	output, err := cmd.Output()
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	fmt.Println(string(output))
}

Kotlin Example

In Kotlin, you can use the ProcessBuilder class to run the command.

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val command = listOf("ZPLPrintDriver.exe", "--path", "C:\\path\\to\\your\\file.zpl", "--printer", "192.168.1.100", "--port", "9100", "--copies", "1", "--timeout", "10")
    val process = ProcessBuilder(command).start()

    val reader = BufferedReader(InputStreamReader(pr...
Read more

V 1.0.0

Choose a tag to compare

@rmunate rmunate released this 27 Sep 00:33

ZPL Print Universal Driver

ZPLPrintDriver.exe is a command-line tool designed to send ZPL (Zebra Programming Language) code to a network printer. It is built to be flexible and can be integrated into any programming language capable of executing console commands.

Features

  • Send ZPL code directly from a file to a Zebra printer over the network.
  • Supports specifying the printer's IP address and port.
  • Allows you to print multiple copies of a label.
  • Configurable timeout for network operations.

Usage

The program can be run from the command line by specifying the required arguments.

Command Line Arguments

  • --path (required): The full path to the ZPL file you want to send to the printer.
  • --printer (required): The IP address of the printer.
  • --port (optional): The port number of the printer. The default is 9100.
  • --copies (optional): The number of copies to print. The default is 1.
  • --timeout (optional): Timeout in seconds for the socket connection. The default is 10 seconds.

Example Usage from Console

ZPLPrintDriver.exe --path "C:\path\to\your\file.zpl" --printer "192.168.1.100" --port 9100 --copies 2 --timeout 10

Explanation of the Example

  • --path: The ZPL file to print is located at C:\path\to\your\file.zpl.
  • --printer: The printer is located at the IP address 192.168.1.100.
  • --port: The printer's port is 9100 (the default for most networked Zebra printers).
  • --copies: The command prints 2 copies of the label.
  • --timeout: The connection will time out if no response is received within 10 seconds.

Using from Other Programming Languages

Python Example

You can invoke the ZPLPrintDriver.exe from Python using the subprocess module.

import subprocess

# Command to run the executable with arguments
command = [
    "ZPLPrintDriver.exe",
    "--path", "C:\\path\\to\\your\\file.zpl",
    "--printer", "192.168.1.100",
    "--port", "9100",
    "--copies", "1",
    "--timeout", "10"
]

# Execute the command
result = subprocess.run(command, capture_output=True, text=True)

# Print the output
print(result.stdout)

C# Example

In C#, you can use the Process class to run the executable.

using System;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        // Create a new process
        Process process = new Process();
        process.StartInfo.FileName = "ZPLPrintDriver.exe";
        process.StartInfo.Arguments = "--path \"C:\\path\\to\\your\\file.zpl\" --printer \"192.168.1.100\" --port 9100 --copies 1 --timeout 10";
        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.UseShellExecute = false;
        process.StartInfo.CreateNoWindow = true;

        // Start the process
        process.Start();

        // Read the output
        string result = process.StandardOutput.ReadToEnd();
        Console.WriteLine(result);

        // Wait for the process to exit
        process.WaitForExit();
    }
}

PHP Example

In PHP, you can use the exec() function to call the executable.

<?php
// Command to execute the ZPL print driver
$command = "ZPLPrintDriver.exe --path \"C:\\path\\to\\your\\file.zpl\" --printer \"192.168.1.100\" --port 9100 --copies 1 --timeout 10";

// Execute the command and capture the output
$output = shell_exec($command);

// Print the output
echo $output;
?>

Ruby Example

In Ruby, you can use the system() function to execute the command.

# Command to run the ZPLPrintDriver.exe
command = 'ZPLPrintDriver.exe --path "C:\\path\\to\\your\\file.zpl" --printer "192.168.1.100" --port 9100 --copies 1 --timeout 10'

# Execute the command
system(command)

Visual Basic (VBScript) Example

In Visual Basic, you can use the Shell function to call the executable.

Set objShell = WScript.CreateObject("WScript.Shell")

' Command to run ZPLPrintDriver.exe
command = "ZPLPrintDriver.exe --path ""C:\path\to\your\file.zpl"" --printer ""192.168.1.100"" --port 9100 --copies 1 --timeout 10"

' Execute the command
objShell.Run command, 0, True

PowerShell Example

In PowerShell, you can run the executable using Start-Process.

# Define the command
$command = "ZPLPrintDriver.exe --path 'C:\path\to\your\file.zpl' --printer '192.168.1.100' --port 9100 --copies 1 --timeout 10"

# Run the command
Start-Process -FilePath "cmd.exe" -ArgumentList "/c $command" -NoNewWindow -Wait

WScript (Windows Script Host) Example

In WScript, you can run the command using the Exec method.

var shell = new ActiveXObject("WScript.Shell");

// Command to run ZPLPrintDriver.exe
var command = 'ZPLPrintDriver.exe --path "C:\\path\\to\\your\\file.zpl" --printer "192.168.1.100" --port 9100 --copies 1 --timeout 10';

// Execute the command
var exec = shell.Exec(command);

// Read and print the output
while (!exec.StdOut.AtEndOfStream) {
    WScript.Echo(exec.StdOut.ReadLine());
}

Error Handling

In case of errors (e.g., invalid printer IP, file not found, etc.), the program will return a JSON response with the following format:

{
  "result": "Fail",
  "error": "Description of the error"
}

On success, the output will look like this:

{
  "result": "Success",
  "path": "C:\\path\\to\\your\\file.zpl",
  "printer": "192.168.1.100",
  "port": 9100,
  "copies": 2
}

License

This project is licensed under the MIT License. See the LICENSE file for details.