PostBridge is a desktop application designed to serve as a communication bridge (middleware) between web applications (such as cloud-based Point of Sale / POS systems) and local thermal printers using the standard ESC/POS protocol. In addition to acting as a print server, PostBridge includes a powerful interactive visual designer that allows users to create, preview, and save ticket templates without writing code.
- Block-Based Editor: Design the ticket structure by adding, reordering (moving up/down), or deleting blocks.
- Supported Components:
- Text: Titles, descriptions, and custom notes.
- QR Codes: Generate and embed QR codes for links, quick payments, or electronic invoicing.
- Barcodes: Insert standard product barcodes.
- Logos and Images: Add company branding or logos directly to the ticket header.
- Separators and Spacers: Add dividing lines and blank spaces for formatting.
- Columns and Dynamic Tables: Design item lists and prices with column alignments.
- Real-Time Preview: View exactly how the ticket will print on thermal paper interactively.
- Template Configuration: Define paper size (e.g., 80 mm or 58 mm), fonts (e.g., Consolas), and manage multiple templates (Create, Rename, Duplicate, Delete).
- Integrated HTTP Server: Exposes a local web service (REST API) running in the background.
- Web Compatibility: Allows any web application to send print jobs in structured formats (such as JSON or HTML) via standard HTTP POST requests.
- HTML-to-Ticket Renderer: Interprets HTML layouts and translates them directly into ESC/POS commands compatible with your thermal printer.
- Multiple Connection Types (Transports):
- Direct USB: Native low-level connection (WinUSB) for USB thermal printers.
- Serial/COM Port: Support for virtual COM ports and traditional serial connections.
- Network/TCP Raw: Send direct commands to network or Wi-Fi printers via TCP sockets.
- Automatic Detection: Uses an auto-configuration and discovery service to identify and link locally connected printers.
- Print Queue Service: Manages concurrent requests sequentially, ensuring tickets are not mixed up or lost during high-volume sales.
- Request Logging (Logs): Stores a local record in SQLite of all received requests, printed tickets, and error states for auditing and troubleshooting in the Requests view.
The code is structured following Clean Architecture principles to maximize maintainability and decouple infrastructure details:
- PostBridge (Presentation - WinUI 3): Intuitive graphical designer interface, connections section, and request monitoring.
- PostBridge.Application: Use cases logic (e.g., PrintTicketUseCase, EncodeTicketUseCase, GetPrintersUseCase).
- PostBridge.Domain: Business entities, enumerations, and contracts/interfaces of the core system (e.g., IEscPosEncoder, IPrinterService).
- PostBridge.Infrastructure: Low-level implementations such as the logs database (SQLite), the web server (HttpBridgeServer), ESC/POS encoders, and transport drivers (UsbDriverService, NetworkRawTransport, SerialRawTransport).
To build and run this project in your local environment, ensure you have the following installed:
- .NET 8.0 SDK (Download .NET).
- Visual Studio 2022 (version 17.8 or later recommended) with the following workloads:
- .NET desktop development workload.
- Universal Windows Platform development or Windows App SDK (WinUI 3).
- ESC/POS Thermal Printer (optional for physical testing; a serial port/printer emulator can also be used).
- Open the
PostBridge.slnxsolution file with Visual Studio 2022. - Restore NuGet packages if necessary (usually automated upon building).
- Select the target build platform (e.g., x64 or x86) in the top toolbar instead of Any CPU, as WinUI 3 requires a specific architecture.
- Choose the startup project:
PostBridge (Package): To run the packaged version (allows clean installation testing).PostBridge: To run the unpackaged application directly.
- Press F5 or click the play/debug button.
To run the unpackaged application directly from the terminal:
- Open a command prompt (PowerShell or CMD) in the project root.
- Run the command:
dotnet run --project PostBridge/PostBridge/PostBridge.csproj -c Debug -f net8.0-windows10.0.19041.0
