Thermal printing from Flutter

Design once in the browser, print from your app on any thermal printer: any paper width, any language, fully offline, and errors that tell you what to fix.

pub.dev version pub points likes MIT license
Made for Flutter and DartAndroidiOSWindowsmacOSLinuxDart server
Any paper width

58, 80, 104, 110, 112 mm or any number of dots. Not just two sizes.

Any language

Malayalam, Hindi, Tamil, Arabic: printed with the phone’s fonts, as a picture.

Templates, not code

Design visually, ship a JSON file, change the layout without an app release.

Never in the dark

Logs at every step, error codes with hints, previews and a printer check.

Install

dependencies:
  fajfield_print_flutter: ^0.1.0   # Flutter apps
  # fajfield_print: ^0.1.0         # plain Dart (server, CLI)

One import gives you everything. The Flutter add-on brings real fonts, FajPreview and FajDebugPanel.

Print in three lines

import 'package:fajfield_print_flutter/fajfield_print_flutter.dart';

final printer = FajPrinter.network('192.168.1.50', paper: Paper.mm110,
    text: FlutterTextRenderer());
final template = PrintTemplate.fromJsonString(jsonFromDesigner);

await printer.print(template, data: {
  'shop': 'Fresh Mart', 'total': '735.00', 'items': items,
});

Samples

Each one is a real template. Download it for your app, open it in the designer, or copy the code.

Shop receipt 80 mm roll

Items table, total and a UPI QR code. The receipt grows with the items.

Open in designer
Dart code
final template = PrintTemplate.fromJsonString(
    await rootBundle.loadString('assets/receipt-80mm.fajfield.json'));

final printer = FajPrinter.network('192.168.1.50',
    language: PrinterLanguage.escpos,
    paper: Paper.mm80,
    text: FlutterTextRenderer());   // real fonts: any language

final job = await printer.print(template, data: {
    'Shop': 'Fresh Mart',
    'Address': 'MG Road, Kochi 682016',
    'Phone': '+91 98470 00000',
    'Bill': 'B-10023',
    'Date': '28/11/2026 12:40',
    'Total': '735.00',
    'UPI': 'freshmart@upi',
    'items': [
      {'name': 'Tea powder 250 g', 'qty': '2', 'rate': '90', 'amount': '180.00', 'hsn': '0902'},
      {'name': 'Coconut oil 1 L', 'qty': '1', 'rate': '245', 'amount': '245.00', 'hsn': '1513'},
      {'name': 'Matta rice 5 kg', 'qty': '1', 'rate': '310', 'amount': '310.00', 'hsn': '1006'},
    ],
});
debugPrint(job.report());

Malayalam receipt 80 mm roll

Any script prints: the receipt is sent as a picture, not with printer fonts.

Open in designer
Dart code
final template = PrintTemplate.fromJsonString(
    await rootBundle.loadString('assets/receipt-malayalam.fajfield.json'));

final printer = FajPrinter.network('192.168.1.50',
    language: PrinterLanguage.escpos,
    paper: Paper.mm80,
    text: FlutterTextRenderer());   // real fonts: any language

final job = await printer.print(template, data: {
    'Shop': 'ഫ്രഷ് മാർട്ട്',
    'Address': 'എം.ജി. റോഡ്, കൊച്ചി 682016',
    'Phone': '+91 98470 00000',
    'Bill': 'B-10024',
    'Date': '28/11/2026 12:44',
    'Total': '425.00',
    'UPI': 'freshmart@upi',
    'items': [
      {'name': 'ചായപ്പൊടി 250 ഗ്രാം', 'qty': '2', 'amount': '180.00'},
      {'name': 'വെളിച്ചെണ്ണ 1 ലിറ്റർ', 'qty': '1', 'amount': '245.00'},
    ],
});
debugPrint(job.report());

GST invoice 110 mm roll

Wide 4-inch receipt printers, with HSN, rate and a bill barcode.

Open in designer
Dart code
final template = PrintTemplate.fromJsonString(
    await rootBundle.loadString('assets/invoice-110mm.fajfield.json'));

final printer = FajPrinter.network('192.168.1.50',
    language: PrinterLanguage.escpos,
    paper: Paper.mm110,
    text: FlutterTextRenderer());   // real fonts: any language

final job = await printer.print(template, data: {
    'Shop': 'Kerala Wholesale Traders',
    'GSTIN': '32ABCDE1234F1Z5',
    'Customer': 'Fresh Mart, MG Road, Kochi',
    'Bill': 'INV-2026-0451',
    'Date': '28/11/2026',
    'Subtotal': '700.00',
    'GST': '35.00',
    'Total': '735.00',
    'items': [
      {'name': 'Tea powder 250 g', 'qty': '2', 'rate': '90', 'amount': '180.00', 'hsn': '0902'},
      {'name': 'Coconut oil 1 L', 'qty': '1', 'rate': '245', 'amount': '245.00', 'hsn': '1513'},
      {'name': 'Matta rice 5 kg', 'qty': '1', 'rate': '310', 'amount': '310.00', 'hsn': '1006'},
    ],
});
debugPrint(job.report());

Small bill 58 mm roll

Compact bill for cafes and counters, long names wrap.

Open in designer
Dart code
final template = PrintTemplate.fromJsonString(
    await rootBundle.loadString('assets/receipt-58mm.fajfield.json'));

final printer = FajPrinter.network('192.168.1.50',
    language: PrinterLanguage.escpos,
    paper: Paper.mm58,
    text: FlutterTextRenderer());   // real fonts: any language

final job = await printer.print(template, data: {
    'Shop': 'Chaya Kada',
    'Bill': '214',
    'Date': '28/11 12:40',
    'Total': '425.00',
    'items': [
      {'name': 'Tea powder 250 g', 'qty': '2', 'rate': '90', 'amount': '180.00', 'hsn': '0902'},
      {'name': 'Coconut oil 1 L', 'qty': '1', 'rate': '245', 'amount': '245.00', 'hsn': '1513'},
    ],
});
debugPrint(job.report());

Product label 50 × 25 mm label

Name, MRP and a scannable barcode, for TSPL or ZPL label printers.

Open in designer
Dart code
final template = PrintTemplate.fromJsonString(
    await rootBundle.loadString('assets/product-50x25.fajfield.json'));

final printer = FajPrinter.network('192.168.1.50',
    language: PrinterLanguage.tspl,
    text: FlutterTextRenderer());   // real fonts: any language

final job = await printer.print(template, data: {
    'Name': 'Cold Pressed Coconut Oil 1L',
    'Price': '245',
    'SKU': 'CCO-1000',
});
debugPrint(job.report());

Shipping label 4 × 6 inch label

Address, order barcode and QR for couriers.

Open in designer
Dart code
final template = PrintTemplate.fromJsonString(
    await rootBundle.loadString('assets/shipping-100x150.fajfield.json'));

final printer = FajPrinter.network('192.168.1.50',
    language: PrinterLanguage.tspl,
    text: FlutterTextRenderer());   // real fonts: any language

final job = await printer.print(template, data: {
    'ToName': 'Anjali Nair',
    'ToAddress': '14 Marine Drive, Kochi, Kerala 682031',
    'Phone': '+91 98470 00000',
    'Order': 'ORD-24117',
    'Weight': '1.2 kg',
    'From': 'Fajfield Foods, Kakkanad, Kochi',
});
debugPrint(job.report());

Design receipts visually

  1. Open the Fajfield designer and pick a receipt (58, 80 or 110 mm), or tick Receipt paper on any design.
  2. Add a Table, name its list (for example items) and set its columns: {{name}}, {{qty}}, {{amount}}.
  3. Use {{fields}} anywhere for shop name, totals, bill number, QR and barcodes.
  4. In Print / Export open For developers and Download template (JSON). Add it to your app’s assets, or load it from your server.
  5. Pass the data: the table adds a row per item and everything below it moves down.

Template data

{
  "shop": "Fresh Mart",
  "bill": "B-10023",
  "total": "735.00",
  "items": [
    { "name": "Tea powder 250 g", "qty": 2, "amount": "180.00" },
    { "name": "Coconut oil 1 L",  "qty": 1, "amount": "245.00" }
  ]
}

Nested values work too: {{customer.name}}.

Connecting

Wi-Fi / LANFajPrinter.network('192.168.1.50') // port 9100
BluetoothFajPrinter.custom((b) => bt.write(b), chunkSize: 180, chunkDelay: Duration(milliseconds: 20))
USBFajPrinter.custom((b) => usb.write(b))
File (.prn)FajPrinter.file('receipt.prn')
No printerFajPrinter.dryRun() // test templates, get a preview
Find printersawait discoverPrinters() // scans the network

Pick the language with language: PrinterLanguage.escpos (receipt printers, the default), .tspl or .zpl. Bluetooth and USB work with any plugin that can write bytes.

Debugging: what happened and why

[fajfield 11:02:41.120 INFO  connect] connected host=192.168.1.50 port=9100 ms=38
[fajfield 11:02:41.301 WARN  template] No value for {{total}}
    → Add "total" to the data you pass to print(), or remove it from the template.
[fajfield 11:02:41.410 INFO  send] sent bytes=18422 ms=109 to=network 192.168.1.50:9100
  • Logs for render, encode, connect, send and status, with timings: PrintLogger.console(LogLevel.debug), or send them to your own logger.
  • Warnings that don’t stop printing: missing fields, things off the paper, text cut, bad barcode data.
  • Preview of exactly what prints, every element outlined: job.preview(debug: true) or FajPreview.
  • Job report to paste in a bug report: job.report(). Raw bytes: job.hex().
  • Printer check: printer.diagnose() for connection, paper, cover and pause; printer.testPage() prints a mm ruler.

Errors you can act on

Every PrintException has a code, a message and a hint.

connectTimeoutPrinter off, or not on the same Wi-Fi. Print its self-test page to see the real IP.
connectRefusedWrong port. Most printers use 9100; some use 9101, 6101 or 515.
hostUnreachableThe phone is on mobile data or a guest Wi-Fi.
tooWideTemplate is 832 dots wide but the paper is 576 (80 mm). Use the right Paper.
writeFailedConnection dropped partway. For Bluetooth, send in chunks.
barcodeInvalidEAN-13 needs 12 digits; the check digit is added for you.

Questions

Is it free?

Yes. Both packages are open source under the MIT license, free for personal and commercial apps. The Fajfield designer is free to use too.

Does it work offline?

Yes. Templates, drawing and printing all happen on the device. Nothing is sent to Fajfield.

Which printers does it support?

Receipt printers that speak ESC/POS (TVS, Epson, Xprinter, Rugtek and most others), label printers that speak TSPL (TSC and many low-cost brands) and ZPL (Zebra and compatibles). Any paper width.

Why does Malayalam (or Hindi, Arabic) print correctly?

Most packages send text to the printer, which only knows a few built-in fonts. fajfield_print draws the whole receipt with the phone’s fonts and sends it as a picture, so any script prints exactly as on screen.

How do I support 110 mm or 4-inch printers?

Use Paper.mm110 (832 dots), or Paper.mm(...) / Paper.dots(...) for any other width. printer.testPage() prints a ruler showing your printer’s real width.

Can business users change the receipt without an app update?

Yes. Templates are JSON files. Load them from your server or app storage, and a new layout from the designer appears without releasing a new app version.

Need labels from a server, ERP or website instead? See the label API and the free ZPL and TSPL tools.

Sign in to Fajfield

Save your labels and open them on any device. It is free.

By continuing you agree to the Terms and Privacy policy.