PrinterWebSocket Framework

A Free Alternative to JSPM & QZ Tray for Silent POS Printing

Build seamless web-based POS systems with direct printer access

View on GitHub Get Started

Introduction

PrinterWebSocket is a lightweight, open-source framework that enables web applications to communicate directly with POS printers through WebSocket connections. Built as a free alternative to commercial solutions like JSPM and QZ Tray, this framework allows silent printing without user prompts, making it perfect for automation and POS systems.

The framework consists of a Python WebSocket server with a built-in GUI for monitoring, and a vanilla JavaScript client that seamlessly integrates into any web application. It supports thermal POS printers using TSPL raw commands and provides real-time printer status monitoring.

โš ๏ธ Development Phase: This project is actively being developed. While it works well with thermal POS printers, support for additional printer models is ongoing. Contributions are welcome!

Key Features

๐Ÿ–จ๏ธ
Silent Printing

Print directly without user prompts or confirmation dialogs. Perfect for automated POS systems and kiosk applications.

๐Ÿ”Œ
WebSocket Communication

Real-time bidirectional communication between web apps and printers using WebSocket protocol.

๐Ÿ“Š
Real-Time Monitoring

Built-in GUI to monitor connected clients, server activity, and printer statuses in real-time.

๐ŸŽฏ
Printer Discovery

Automatically list all available printers connected to the server with their current status.

โšก
TSPL Support

Native support for TSPL commands for thermal POS printers with raw command execution.

๐ŸŒ
Cross-Platform

Works on Windows, macOS, and Linux. Currently optimized for Windows with pywin32.

Architecture

Server Components

  • printer_server.py - Main WebSocket server with printer handling
  • requirements.txt - Python dependencies
  • Built-in GUI for monitoring and client management
  • Real-time logging and error tracking

Client Components

  • PrinterWebSocket.js - Vanilla JavaScript client library
  • Promise-based API for async operations
  • Automatic connection management
  • Event-driven architecture

Installation & Setup

Prerequisites

Make sure you have the following installed:

Step 1: Install Dependencies

Step 2: Start the Server

Run the WebSocket server with the built-in GUI:

The server will start on port 8765 by default. You can modify this in the server code.

Step 3: Include Client Library

Add the JavaScript client to your web application:

Quick Start Guide

Initialize Connection

Establish a WebSocket connection to the printer server:

Send a Print Job

Send TSPL commands to print a receipt or label:

Complete Example

A full working example with printer selection:

API Reference

1. List Available Printers

Retrieve all printers connected to the server.

Request

Field Value
call "printers.find"
uid "unique-request-id"

Response

2. Get Server Version

Check the current version of the printer server.

Request

Response

3. Send Print Job

Send TSPL commands to a specific printer for printing.

Request

Field Value
call "print"
uid "unique-request-id"
params.printer.name "Gprinter GP-3120TUC"
params.data Array of TSPL commands

Success Response

Error Response

4. Check Printer Status

โš ๏ธ Experimental Feature: This feature is still in testing and may not work with all printers. There are limitations in the pywin32 library for retrieving real-time printer status.

Request

Response Examples

Idle Printer:

Printing:

Error State:

Status Codes

Code Status Description
0 Success / Idle Operation completed successfully or printer is idle
1 Printing Printer is currently processing a print job
3 Error Printer encountered an error or operation failed

Use Cases & Examples

Restaurant POS System

Print kitchen orders and customer receipts automatically:

Retail Label Printing

Generate product labels with barcodes:

Shipping Label System

Create shipping labels with tracking information:

Testing & Development

WebSocket Testing Tools

You can test the server using various WebSocket clients:

Example Test with Browser Console

Server GUI Features

The built-in GUI provides:

  • Real-time server activity logging
  • Connected clients list with details
  • Error tracking and diagnostics
  • Connection status monitoring
  • Print job history
  • Server configuration display

Troubleshooting

Common Issues

Connection Refused

Problem: Cannot connect to ws://localhost:8765

Solution:

Printer Not Found

Problem: Printer doesn't appear in the list

Solution:

Print Job Fails

Problem: Print command returns error

Solution:

Windows-Specific Issues

Problem: pywin32 installation errors

Solution:

Known Limitations

Platform Compatibility

Currently optimized for Windows environments using pywin32. Support for macOS and Linux is planned but may require additional development for printer interactions.

Printer Status Retrieval

The printer status feature has limitations due to pywin32 library constraints. It can create print jobs successfully, but real-time status monitoring may not work with all printer models.

Printer Model Support

Tested primarily with thermal POS printers using TSPL commands. Support for other printer types and command languages is in development. Community testing and contributions are welcome!

Contributing

PrinterWebSocket is an open-source project and welcomes contributions! Here's how you can help:

๐Ÿ› Report Issues

Found a bug? Report it on our GitHub Issues page with details about your printer model and environment.

๐Ÿ”ง Submit Pull Requests

Have a fix or new feature? Fork the repository, make your changes, and submit a pull request for review.

๐Ÿ“ Improve Documentation

Help others by improving documentation, adding examples, or translating content.

๐Ÿงช Test with Different Printers

Test with various printer models and share your results to improve compatibility.

Downloads

Get the latest version of PrinterWebSocket from GitHub:

Project Files

File Description
printer_server.py Main WebSocket server with printer handling and GUI
PrinterWebSocket.js Vanilla JavaScript client library for web applications
requirements.txt Python dependencies list
README.md Project documentation and usage guide

Contact & Support

Have questions or need support? Get in touch with us:

๐Ÿ’ฌ
GitHub

Open an Issue

๐Ÿ“›
Facebook

@tawsiftorabi

Community Links

Connect with the PrinterWebSocket community

GitHub Issues LinkedIn Facebook

License & Credits

PrinterWebSocket is an open-source project created as a free alternative to commercial solutions like JSPM and QZ Tray.

Author: Tawsif Torabi
Repository: github.com/TawsifTorabi/PrinterWebsocket

This project is provided as-is for educational and commercial use. While it's free to use, contributions and support are always welcome to help improve the framework for everyone.