Open Application Platform Docs

Installation

The sPrint packages for each platform and the first call on each.

Version 0.1.6. Every package of a release has the same version and the same printing engine.

Platform Package Requirements
C# / .NET Superroute.SPrint .NET 8 — Windows, macOS, Linux
Python superroute-sprint Python 3.9+ — Linux, macOS, Windows
Dart / Flutter sprint_flutter Dart 3.5+, Flutter — Android, iOS, macOS, Windows, Linux
Swift (iOS, macOS) SPrint iOS 15+, macOS 13+
Kotlin / Android ca.superroute:sprint Android 7+ (API 24)
C / C++ sprint-0.1.6-<os>-<arch> macOS (arm64, x86-64), Linux (x86-64, arm64, armv7), Windows (x64, arm64)
Go (cgo) sprint-0.1.6-<os>-<arch> Go with cgo, over the C library

License: Superroute SDK License

Platforms

Platform Network printers USB printers System print queues Classic Bluetooth Bluetooth LE LAN peer printing
Windows Supported Supported1 Supported2 Supported Supported Supported
macOS Supported Supported3 Supported4 Supported Supported Supported
Linux and Raspberry Pi Supported Supported5 Supported4 Supported Supported Supported
Android Supported Supported6 Not applicable Supported Supported Supported
iOS Supported Not supported7 Not applicable Not supported8 Supported Supported

Supported · Not supported · Not applicable

  1. Windows: direct, through the USB printer class.
  2. Windows: the Windows print queues.
  3. macOS: direct, without a print queue.
  4. macOS, Linux and Raspberry Pi: CUPS.
  5. Linux and Raspberry Pi: direct, through usblp.
  6. Android: USB host, with an OTG cable.
  7. iOS gives apps no USB printers.
  8. iOS gives apps Bluetooth LE only.

Every package (C library, .NET, Python, Swift, Android, Flutter) offers the same capabilities on the same platform.

C# / .NET

dotnet add package Superroute.SPrint --version 0.1.6

Python

pip install superroute-sprint==0.1.6

Dart / Flutter

On iOS and macOS the plugin needs Swift Package Manager support in Flutter. On Windows and Linux the build downloads the C library of the same version and checks its checksum.

flutter pub add sprint_flutter:0.1.6

Swift (iOS, macOS)

Add the Swift package in Xcode or in Package.swift.

.package(url: "https://github.com/Goodneo-Solutions/sprint-releases", from: "0.1.6")
// product: "SPrint"

Kotlin / Android

Add the Maven repository, then the package.

repositories {
    maven { url = uri("https://goodneo-solutions.github.io/sprint-releases/maven") }
}
implementation("ca.superroute:sprint:0.1.6")

C / C++

Download the archive for your system and processor from the Releases page of the release repository. Each archive holds the header sprint.h and the shared and static library. The Linux libraries need glibc 2.31 or later.

# sprint-0.1.6-linux-arm64.tar.gz from the release, then:
cc app.c -Isprint-0.1.6-linux-arm64/include -Lsprint-0.1.6-linux-arm64/lib -lsprint

Go (cgo)

Go programs use the C library through cgo: unpack the archive next to the program and point cgo at its include and lib folders.

/*
#cgo CFLAGS: -I${SRCDIR}/sprint/include
#cgo LDFLAGS: -L${SRCDIR}/sprint/lib -lsprint -Wl,-rpath,${SRCDIR}/sprint/lib
#include <stdlib.h>
#include "sprint.h"
*/
import "C"

First call

Each call below finds the printers on the local network, saves one of them in a printer registry and prints a label on it.

// C# / .NET
using Superroute.SPrint;

var found = Discovery.ScanNetwork();
using var printers = new PrinterRegistry("printers.json");
printers.Save(new TargetPrinter { Name = "Labels", Host = found[0].Host, Transport = Transports.Network, Language = Languages.Zpl });
var result = printers.Print(new PrintJob { Type = JobTypes.Label, Label = LabelJob.Parse(labelJson) });
# Python
from superroute_sprint import Discovery, PrinterRegistry, TargetPrinter, PrintJob, LabelJob, Languages, Transports, JobTypes

found = Discovery.scan_network()
with PrinterRegistry("printers.json") as printers:
    printers.save(TargetPrinter(name="Labels", host=found[0].host, transport=Transports.NETWORK, language=Languages.ZPL))
    result = printers.print(PrintJob(type=JobTypes.LABEL, label=LabelJob.parse(label_json)))
// Dart / Flutter
import 'package:sprint_flutter/sprint_flutter.dart';

final found = await Discovery.scanNetwork();
final printers = await PrinterRegistry.open('${dir.path}/printers.json');
await printers.save(TargetPrinter(name: 'Labels', host: found.first.host, language: Languages.zpl));
final result = await printers.print(PrintJob(type: JobTypes.label, label: LabelJob.parse(labelJson)));
// Swift (iOS, macOS)
import SPrint

let found = try Discovery.scanNetwork()
let printers = try PrinterRegistry(path: "printers.json")
try printers.save(TargetPrinter(name: "Labels", host: found[0].host, language: Language.zpl))
let result = try printers.print(PrintJob(type: JobType.label, label: try LabelJob.parse(labelJSON)))
// Kotlin / Android
SPrint.init(context)
val found = Discovery.scanNetwork()                     // off the main thread
val printers = PrinterRegistry(File(filesDir, "printers.json").path)
printers.save(TargetPrinter("Labels", found.first().host, Transports.NETWORK, language = Languages.ZPL))
val result = printers.print(PrintJob(JobTypes.LABEL, label = LabelJob.parse(labelJson)))
// C / C++
#include "sprint.h"

char *found = sprint_scan_network("", 350);   /* {"printers": [...]} */
char *res = sprint_print("{\"name\":\"Labels\",\"host\":\"192.168.1.40\",\"transport\":\"network\",\"language\":\"zpl\"}",
                         label_job_json);           /* {"type":"label","label":{...}} */
sprint_free(found);
sprint_free(res);
// Go (cgo)
found := C.sprint_scan_network(C.CString(""), 350)
defer C.sprint_free(unsafe.Pointer(found))
printer := C.CString(`{"name":"Labels","host":"192.168.1.40","transport":"network","language":"zpl"}`)
job := C.CString(labelJobJSON) // {"type":"label","label":{...}}
res := C.sprint_print(printer, job) // PrintResult JSON
defer C.sprint_free(unsafe.Pointer(res))

A label is JSON: its size in millimetres and its elements, each placed in millimetres from the top left corner.

{"version": 1, "width_mm": 50, "height_mm": 30, "elements": [
  {"type": "text", "x": 2, "y": 2, "w": 46, "h": 6, "text": "PLD-01J2XYZ", "size_pt": 10, "bold": true},
  {"type": "barcode", "x": 2, "y": 10, "w": 46, "h": 14, "value": "PLD01J2XYZ", "show_value": true},
  {"type": "qr", "x": 36, "y": 2, "side": 8, "value": "https://example.com/t/PLD01J2XYZ"}
]}

Third-party software

On Windows sPrint prints PDF documents to a printer driver with SumatraPDF 3.5.2, a separate program shipped unmodified in the .NET package under its own licence, the GNU General Public License version 3. The notice and the licence text are in the release repository, and the notice names where the source code of that version is.

THIRD-PARTY-NOTICES.txt · SumatraPDF 3.5.2