Printing guide
Server-side label printing for .NET
Print a label with no user session, no browser and no print dialog. What that means, four ways to build it, and how to choose between them.
What server-side printing means
Server-side label printing starts in a program, not in a person's browser tab. An order is packed or a parcel gets its tracking number, and a service builds the label and sends it to a printer. Nobody is signed in, no browser is open and no print dialog appears. It is also called headless, backend or unattended printing. Shipping labels in BarcoderX covers what a parcel label carries and how it prints. Manufacturing labels, warehouse labels, returns labels and automotive supplier labels are other labels a service can print with nobody at the keyboard.
That moves work onto your code that a person used to do: pick the printer, notice the paper has run out, press print again. A service must know which printer to use, send data in a language the printer understands, find out whether the label came out, and recover when it did not.
The label itself is the easy half. Thermal printers read a command language such as ZPL, a short piece of text. This is a whole label, explained in the ZPL guide:
^XA ^FO40,30^A0N,40,40^FDBin A17^FS ^XZ
One text field, 40 dots from the left and 30 down. Zebra is the printer brand most people associate with this language.
The hard half is getting those bytes to the printer reliably, from a machine that is usually not on the printer's network. The four architectures below are four answers to that problem.
Four architectures at a glance
They differ in one thing: what carries the bytes from the program that holds the label to the printer. Choose by where your code runs and who controls the printer's network.
| Architecture | What reaches the printer | What it needs | It fits when |
|---|---|---|---|
| A. Direct over the LAN | Your server opens a TCP connection to the printer, usually on port 9100, and writes the label. | A network route from the server to the printer. | Server and printers share a site network, and you control both ends. |
| B. Print queue and outbound-only agent | A server you run, on your own hardware or in your own cloud account, queues the job. An agent where the printers are holds an outbound connection to that server, collects the job and writes it to the printer. | The queue server, an agent at each site, and outbound HTTPS from the agent. | You serve many sites you do not control, or run a multi-tenant product. |
| C. The printer maker's cloud service | The maker's cloud holds the printer's outbound connection. Your server sends the job to the maker's API. | Printer models that offer the service, and an account. | You standardize on one brand and accept the maker's terms. |
| D. Spooler or CUPS | Your server hands the job to the operating system's print queue, which passes it to the printer. | The printer installed on the server, or a reachable print server. | IT already manages the queues, or the printer is on USB. |
A. Direct to a LAN printer over TCP
Raw printing on port 9100 is a long-standing industry convention. The printer listens on that TCP port, you connect, write the bytes of the label and close. No driver, spooler or page rendering sits in between, so the label arrives as you built it. Send ZPL to a Zebra printer from C#
It is the simplest architecture and behaves the same on Windows and Linux. TCP carries data both ways, so many printers also answer status queries on the same connection. What a printer answers depends on its language and model.
It has three limits. The raw port has no sign-in or encryption, so keep it on a private network and never expose it to the internet. A successful write means the printer took the bytes, not that a label came out. And a server in a data center cannot reach a printer in a warehouse without a VPN or tunnel.
BarcoderXThe SDK packages print from your own process over TCP port 9100, with no API server and no agent, and read the printer's status in full. The BarcoderX API server never opens a connection to a printer address you supply. It reaches printers through the print agent.
B. A print queue and an outbound-only agent
Printers often sit on networks you do not control, and a server cannot reach in without an inbound port, which few network teams will open. This architecture turns the connection around: a small agent inside the printers' network dials out to your server, holds the connection open and prints whatever arrives. The server can run on your own hardware or in your own cloud account.
For the sender, printing becomes a record in a queue instead of a socket write. The job has a state you can read, it survives an offline agent, and your code never needs a route to the printer.
The costs are one more component to install and update at each site, a queue server you run and secure, and delivery rules to get right. After a dropped connection a job may arrive twice, so the agent must recognize one it has already printed.
BarcoderXBarcoderX provides both halves, and you run both: the API server that holds the queue and the print agent. Your code queues a job through the REST API. The agent, a Windows service or a systemd daemon on Linux, dials out to your server over HTTPS and WebSocket and listens on nothing. The server signs every job, the agent checks the signature, and delivery is at-least-once with de-duplication by job id.
How the print agent works The print agent: pairing, connection and jobs
C. The printer maker's own cloud service
Some printer makers run a cloud service of their own. The printer, or software from the maker, keeps an outbound connection to the maker's cloud, and your server sends jobs to the maker's API instead of to the printer.
The appeal is that nothing extra is installed at the site, if the printer supports it. The trade-offs are those of any third-party dependency. It works only with the brands and models that offer it, so a mixed fleet needs more than one integration. Your label data passes through the maker's cloud. Availability, limits and prices are the maker's to set. Read the maker's documentation for supported models and terms before you commit.
BarcoderXBarcoderX reaches printers directly from your own process, or through its print agent. It has no route through a printer maker's cloud print service.
D. The operating system's spooler or CUPS
Every server operating system has a print queue. On Windows it is the print spooler. On Linux it is CUPS. Your server hands the job to the queue and the queue passes it to the printer.
Label printers need the job to arrive untouched. On Windows, a job sent with the RAW data type goes to the printer as written, without the driver redrawing it. CUPS has an equivalent raw mode for files already formatted for the printer, such as ZPL. Newer CUPS releases are moving toward driverless queues, so check how your distribution handles raw jobs before you rely on it.
A queue gives you what a bare socket does not: pause, cancel, ordering and a place for an administrator to look. It gives you less on status. You learn what the queue did, not what the printer did, so a job can show as finished while the printer is out of media.
One Windows trap catches many services: printers added under a user account belong to that user, and a service runs under its own account and does not see them. Install the printer for the machine.
BarcoderXThe SDK packages print through the Windows spooler (RAW) and through CUPS. These transports report queue and job state only, and the API says so.
The life of a print job, and what goes wrong
Whatever the architecture, a job passes through the same steps: accepted, queued, delivered, written and printed. Treating printing as one call hides every place it can fail. These are the states BarcoderX shows for a job sent through the agent:
- Queued
- Dispatched
- Received
- Spooled
- Printed
A job can also end as Failed, Canceled or Expired. You read its state with GET /print-jobs/{id} and cancel it with POST /print-jobs/{id}/cancel, relative to /api/v1.
- Retries that print twice
- A client that retries after a timeout can send the same job twice. Send an idempotency key with every job; BarcoderX honors one on print jobs. On the receiving side, de-duplicate by job id, or a redelivery prints a label twice.
- An offline printer or agent
- Decide how long a job is worth keeping. A pick label for yesterday's orders should not print this morning. In BarcoderX, a job for an offline agent waits until its expiry, which each tenant can set, and a job whose agent is lost before it acknowledges goes back to Queued.
- Printer faults
- Out of media, out of ribbon, head open. You see these only over a transport that reads status: TCP, serial and USB can report in full, the spooler and CUPS report queue state only. Show the fault to someone who can fix it, and do not retry forever.
- A label that cannot be drawn as designed
- Reject the job with a diagnostic instead of printing something different. That is how BarcoderX treats an element nothing can reproduce.
Security: no inbound ports, no shared data
- No inbound ports
- In the agent design the only connection is outbound, over HTTPS and one WebSocket, through the system proxy or a configured one. Nothing listens.
- Trust the sender, not the network
- Raw port 9100 has no sign-in, so it stays on a private network. In the queued design the agent checks the server's signature on every job before anything reaches a printer. A one-time pairing code, valid for ten minutes, enrolls the agent. Its private key never leaves the machine, and revoking an agent closes its connection at once.
- Tenant isolation
- If your server prints for many of your own customers, isolation has to be a database rule, not a habit. In BarcoderX the tenant comes from the credential and never from a parameter, with row-level security on every tenant table and an append-only audit log. Print payloads use per-tenant keys and are deleted after a retention period. API keys carry scopes, an expiry and an optional IP allow-list.
These controls follow common security practice. This is not a certification or an attestation report.
Running on Windows and Linux
The BarcoderX engine gives byte-identical output on Windows x64, Linux x64 and Linux arm64, so the label built on a developer's laptop is the label the server prints. What differs between systems is how the bytes reach the printer.
| Transport | Windows | Linux | Printer status |
|---|---|---|---|
| TCP, port 9100 | Yes | Yes | Full query and response |
| Serial | Yes | Yes | Full query and response |
| Windows spooler, RAW | Yes | Not applicable | Queue and job state only |
| CUPS | Not applicable | Yes | Queue and job state only |
| USB, raw device | Not applicable | Yes | Full query and response |
The print agent runs as a Windows service on Windows 10, Windows 11 and Windows Server 2019 or later, or as a systemd daemon on Linux x64 and arm64.
Before you pick where to run your server, check that your code can open outbound connections to the printers' addresses and, for a spooler, that the machine has one.
High volume, honestly
A thermal printer prints one label at a time, from a buffer of limited size, at a speed the printer sets. At high volume the printer, not your server, controls the pace. The design question is how to feed it without losing or repeating labels.
- Keep one writer per printer. Queue jobs per printer and send them one after another.
- Send a large batch as a single job, not a connection per label.
- Let the printer repeat work. For labels that share static content, BarcoderX stores it on the printer once, recalls it for each label and deletes it at the end of the job by default.
- Expect to be told to slow down. The BarcoderX API limits each tenant's request rate and answers with a Retry-After header.
BarcoderX has not published throughput figures, and this page does not invent any. Measure with your own printers, label designs and network before you promise a rate to anyone.
Where BarcoderX fits
BarcoderX covers routes A, B and D, and you run every part of it: nothing in it is a service we operate. In your own .NET process, the SDK packages lay a label out once and print it over TCP, serial, the Windows spooler, CUPS or USB. For queued printing, you run the API server and the print agent, and your code queues jobs through the REST API.
The browser never calls a port on your machine. If the print button lives in a web app, print thermal labels from a web app: four ways compares the options from that side.
Keep reading
Print thermal labels from a web app: four ways Thermal label printing and export The REST API For developersNew to the printer language? Read the ZPL guides and command reference.
Background General technical background from the Microsoft documentation on sending raw data to a printer and the CUPS documentation. What this page says about BarcoderX comes from its printing, API, platform, developers and FAQ pages.
Written by BarcoderX in its own words.
Zebra, ZPL and ZPL II are trademarks of Zebra Technologies Corporation. BarcoderX is an independent product and is not affiliated with, endorsed by or sponsored by Zebra Technologies.