Blueline
2.0.1indexedSimplifies Bluetooth printer integration with platform-agnostic API for discovering, connecting, and managing printers. Supports rich text formatting, seamless image printing, and custom command support for advanced control.
Simplifies Bluetooth printer integration with platform-agnostic API for discovering, connecting, and managing printers. Supports rich text formatting, seamless image printing, and custom command support for advanced control.
BlueLine is a Kotlin multiplatform library that simplifies Bluetooth printer integration in your applications. It provides a platform-agnostic API for common printer operations across mobile platforms (Android, iOS).
Key Features:
BlueLine is easy to integrate into your Kotlin multiplatform project. Here's a quick guide:
Add BlueLine to your dependencies:
// In your root build.gradle.kts file
repositories {
mavenCentral()
}
kotlin{
sourceSets {
commonMain.dependencies{
//old - pre 2.0.0
implementation()
implementation()
implementation()
}
}
}
Here's an example demonstrating how to print some formatted text and an image using basic builder:
Here's an example using compose builder:
import com.dilivva.blueline.compose.*
fun main() {
val blueLine = BlueLine()
//Monitor Connection state
val connectionState = bluetoothConnection.connectionState() //StateFlow<ConnectionState>
composeBuilder = rememberComposeBuilder()
blueLine.scanForPrinters()
blueLine.connect()
composeBuilder.drawContents {
PreviewPeopleTable()
}
result = composeBuilder.create()
blueLine.print(result.)
result.preview
}
We welcome contributions to Blueline!
Blueline is licensed under the MIT License. See the LICENSE file for details.
Explore the API:
import com.dilivva.blueline.basic.*
fun main() {
val blueLine = BlueLine()
//Monitor Connection state
val connectionState = bluetoothConnection.connectionState() //StateFlow<ConnectionState>
//Scan for printers
blueLine.scanForPrinters()
//Connect
blueLine.connect()
//Build print data
val result = buildPrintData {
appendImage {
imageBytes = bytes
}
appendText {
styledText(data = "Send24", alignment = Config.Alignment.CENTER, font = Config.Font.LARGE_2, style = Config.Style.BOLD)
textNewLine()
styledText(data = "================================", alignment = Config.Alignment.CENTER, style = Config.Style.BOLD)
textNewLine()
text("Name: Bob Oscar")
textNewLine(2)
text("Phone: +111111111")
textNewLine(2)
styledText(data = "Variant:", font = Config.Font.NORMAL, style = Config.Style.BOLD)
text("HUB_TO_HUB")
}
}
//print
blueLine.print(result.data)
//preview
result.preview
}
Surfaced from shared tags and platforms — no rankings paid for.