NetworkPrinterManager

simpos · android/app/src/main/java/com/onereva/simpos/manager/NetworkPrinterManager.kt · kotlin · MIT
integration, pos, tag:escpos, tag:tcp-printer, tag:thermal-printer, tag:bitmap-splitting

TCP-based ESC/POS network printer abstraction. Splits large bitmaps and sends to any IP:9100 thermal printer.

// Source: https://github.com/hieuhani/simpos | License: MIT
// Provided via justclaw.it.com; keep this notice with the code.
package com.onereva.simpos.manager

import android.graphics.Bitmap
import com.dantsu.escposprinter.EscPosPrinter
import com.dantsu.escposprinter.connection.tcp.TcpConnection
import com.dantsu.escposprinter.textparser.PrinterTextParserImg


class NetworkPrinterManager {
    fun splitBitmap(bitmap: Bitmap): Array<Bitmap?>? {
        val partHeight = 50
        val parts = Math.ceil(bitmap.height.toDouble() / partHeight).toInt()
        val bitmaps = arrayOfNulls<Bitmap>(parts)
        for (i in 0 until parts) {
            bitmaps[i] = Bitmap.createBitmap(bitmap, 0, partHeight * i, bitmap.width, if (i == bitmaps.size - 1) bitmap.height - (parts - 1) * partHeight else 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key