Open tjolsen-vn opened 2 months ago
Also, doing text based printing with:
printer.addText(text)
works as far as sizing. But it is much harder to maintain good word wrapping and text styles. It would be much better for us to be able to move away from this text based printing and move forward with bitmap printing (we create the bitmap with html which is much easier to style).
Also tried doing things this way:
fun createNewOrderChit(
context: Context,
order: Order,
isSuites: Boolean,
) {
Log.d("PRINT_TEST", "Calling createNewOrderChit...")
val print = Print(context)
try {
val printerOrderData = order.toPrinterOrderData(context.resources, isSuites)
val printImage = imageFactory.createOrderChitBitmapImage(
context,
printerOrderData,
PrinterType.fromValue(order.printerType ?: ""),
)
if (printImage == null) {
Log.e("TEST_PRINT", "print image is null")
return
}
// val model = "TM-T88VI"
val model = "TM-U220"
val builder = Builder(model, Builder.MODEL_ANK)
builder.addImage(
printImage,
0,
0,
printImage.width,
printImage.height,
Printer.PARAM_DEFAULT,
Printer.PARAM_DEFAULT,
Printer.PARAM_DEFAULT,
3.0,
Printer.PARAM_DEFAULT,
)
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
builder.addCut(Printer.CUT_FEED)
val printStatusArray = intArrayOf(0)
val batteryStatusArray = intArrayOf(0)
print.openPrinter(Print.DEVTYPE_TCP, ipAddress)
print.getStatus(printStatusArray, batteryStatusArray)
print.beginTransaction()
print.sendData(builder, 10000, printStatusArray)
print.endTransaction()
print.closePrinter()
} catch (e: Exception) {
CrashlyticsHelper.logException(e)
PrinterLogger.logException(e, "createOrderChit", context)
Log.e("PRINT_TEST", e.message, e)
}
}
As a quick test. Switching between the printer models. This also works for the TM-T88VI
, but this way I get no print at all for the U220B
.
@EPSONePOS Any insights?
I'm getting the model names from here: https://github.com/EPSONePOS/ePOS/blob/master/ePOSPrint/src/main/res/values/strings.xml
For some reason when I send a print command on a![IMG_2264](https://github.com/EPSONePOS/ePOS/assets/54280016/6bc939b1-bdac-4e35-bc14-af8a8e14b59f)
U220
,addImage()
isn't working as I would expect The printer doesn't seem to respect the paper width:I've tried changing the width of the bitmap, but the image is still huge, it just doesn't print the full width of the paper. For example:![IMG_2265](https://github.com/EPSONePOS/ePOS/assets/54280016/89c84c87-c392-443b-956f-3b6c7f3233e0)
For the
U220
, I set up my printer like:For the
TM T88VII
, I set up the printer like:Then I call
addImage()
:Things work as expected on the thermal printer, but not the impact. Another interesting note, if I do
Printer(Printer.TM_T88, Printer.MODEL_ANK, context)
when sending a command to theU220
, it fails to connect. If I doPrinter(Printer.TM_U220, Printer.MODEL_ANK, context)
for theTM T88VII
, it will connect, but print the image blown up like in the impact prints above.This could very well be a me issue but I'd really appreciate some guidance.