Lorixen.
EN

Printing labels from a web app on thermal printers

Short answer: A web app can print to a thermal label printer in three ways: through the browser's normal print dialog with a page sized to the label, by sending raw printer commands (such as Zebra's ZPL) through a small local agent or a hosted print service, or, in some browsers, directly over USB. Browser printing is quickest to build but fiddly for staff; raw printing is fast and exact but needs a helper on each computer. Decide which before development starts, because it shapes the whole feature.

Label printing is one of those features that sounds trivial in a project brief ("and it prints a label") and then eats a week of testing. Labels come out tiny, shifted, cut in half or blank. Almost all of these problems trace back to a mismatch between how the web app produces the label and how the printer expects it. The table below maps common symptoms to causes, followed by a checklist for writing the spec.

The three printing routes

1. Browser print dialog. The app renders the label as a web page, and CSS sets the page size to the label dimensions. MDN's reference for the @page size descriptor shows absolute sizes such as size: 4in 6in; alongside named paper sizes. The user then picks the label printer in the print dialog. No extra software, but it depends on the printer driver and on staff choosing the right settings each time.

2. Raw commands via an agent or print service. The app generates the label in the printer's own language and sends it straight to the printer, skipping the driver's page rendering. Zebra's Enterprise Browser printing guide lists ZPL, CPCL and EPS among the languages Zebra printers support. Because a website can't normally reach a printer on its own, something has to relay the job:

  • A local agent from the printer maker, installed on each computer, that the web page talks to.
  • A hosted print service such as PrintNode, whose documentation describes a client on the computer connected to the printer and accepts PDF documents or RAW print jobs submitted through its web app or API. This also lets a server print without anyone clicking anything.

3. WebUSB. Some browsers let a web page talk to a USB device directly after the user grants permission. MDN's WebUSB page marks it as experimental, not Baseline because it doesn't work in some widely used browsers, and available only in secure contexts (HTTPS). Useful for a controlled setup, such as one browser on one packing bench, but not a general solution.

Symptom → cause → fix

Symptom Likely cause Fix
Label prints tiny in a corner Browser printed an A4/Letter page scaled onto the label Set @page size to the label size and turn off scaling ("fit to page") in the dialog; or switch to raw printing
Label is cut across two labels Page size and label size differ, or printer not calibrated to the media Match sizes exactly; run the printer's media calibration
Margins or headers appear (date, URL) Browser adds headers and footers Disable headers and footers in print settings; raw printing avoids this
Barcode won't scan Barcode scaled or blurred by the driver; bars too thin for the printer's resolution Generate barcodes at the printer's native resolution; prefer raw commands for barcodes
Text looks fuzzy or bold Rasterized image scaled to a different DPI Design labels for the printer's actual DPI
Nothing prints, no error Agent not running, or the printer was renamed Health check in the app that shows agent and printer status before printing
Prints on the wrong printer Default printer changed on the computer Let users select and save a label printer in the app, not in the OS
Works on Windows, not on the tablet Tablet browser has no driver or agent route Use a print service or network printing that the tablet can reach
Staff click print three times Slow feedback Show "sent to printer" immediately and log each job

Label sizes, DPI and barcodes

Thermal printers print dots, and every printer has a fixed resolution. Check your model's spec sheet; 203 dpi and 300 dpi are common figures on many models. At low resolutions, tiny text and dense barcodes become unreadable, so:

  • Design at the real label size in inches or millimeters, then convert to dots for raw commands (dots = inches × dpi).
  • Keep barcode bar widths whole numbers of dots. Scaling a barcode by a non-whole factor is the classic reason a label looks fine and doesn't scan.
  • Leave a quiet zone around barcodes.
  • Test with the actual scanner your staff use, not just a phone app.

Printing from tablets and phones

Warehouse and market staff increasingly work on tablets. Browser print dialogs on tablets often can't reach a thermal printer at all. Options:

  • A network-connected printer plus a print service or agent running on another computer.
  • A hosted print service, so the tablet only talks to your web app and the server sends the job.
  • A printer maker's own mobile tools, where available for your model and operating system; check the maker's current documentation.

Spec checklist for your developer

Use this when commissioning the feature:

  • [ ] Printer models and connection type (USB, network, Bluetooth) at each location
  • [ ] Label sizes, with a physical sample and the printer's DPI
  • [ ] Which devices print: Windows, Mac, Chromebook, tablets
  • [ ] Route chosen: browser print, local agent, hosted service or WebUSB, and why
  • [ ] Label templates with fields, fonts and barcode types (Code 128, QR, etc.)
  • [ ] Batch printing: one label or a run of 50 at once?
  • [ ] Reprints: can staff reprint without creating a duplicate record?
  • [ ] Error handling: what the user sees when the printer is offline or out of labels
  • [ ] A print log with time, user, printer and job status
  • [ ] Testing plan with real printers, real labels and the real scanner

FAQ

Can a website print to a label printer without installing anything?

Yes, through the browser's print dialog, if the page is sized to the label. It's the least reliable route for barcodes and repeated use.

What is ZPL?

It's one of the command languages Zebra printers understand, alongside others such as CPCL and EPS. The app describes the label in text commands and the printer renders it itself.

Is WebUSB ready for production?

MDN lists it as experimental and not supported in some major browsers. It can work in a controlled environment with a known browser.

Do we need a hosted print service?

Not always. It helps when printing must happen from servers, tablets or several sites without someone clicking print.

Specifying an order or stock app where labels need to print right first time? Send us your printer models and label sizes. You can read how we approach order, stock and other business apps on our web app development page.

Sources

WhatsAppLet’s talk