Shoaib Anwar
Shoaib Anwar

Reputation: 849

How to configure Build In POS printer with android PrintService

I have PAX A920 and i am trying to print receipt from chrome. I wan to configure printer service in android for print receipt from my build in printer I have write printer service for local printer and its is showing in preview, but I don't know how to configure build in printer. This is code for local printer

final List<PrinterInfo> printers = new ArrayList<>();
            final PrinterId printerId = generatePrinterId("Pax-printer:built-in");
            Log.e("the", "the local printer id is " + printerId);
            final PrinterInfo.Builder builder = new PrinterInfo.Builder(printerId, "POS Printer", PrinterInfo.STATUS_IDLE);
            PrinterCapabilitiesInfo.Builder capBuilder = new PrinterCapabilitiesInfo.Builder(printerId);
            capBuilder.addMediaSize(PrintAttributes.MediaSize.ISO_A6, true);
            capBuilder.addMediaSize(PrintAttributes.MediaSize.ISO_A3, false);
            capBuilder.addResolution(new PrintAttributes.Resolution("resolutionId", "default resolution", 600, 600), true);
            capBuilder.setColorModes(PrintAttributes.COLOR_MODE_COLOR | PrintAttributes.COLOR_MODE_MONOCHROME, PrintAttributes.COLOR_MODE_COLOR);
            builder.setCapabilities(capBuilder.build());

            printers.add(builder.build());
            addPrinters(printers);

I am also getting Document object

final PrintDocument document = printJob.getDocument();

enter image description here

but I can not utilize this document to set in customer printer, my customer printer accept payload of text and bitmap. here is code for printing from PAX A920

PrintPayload payload = new PrintPayload();
             payload.append(bmp).align(Alignment.CENTER);
             print(payload);

How can i convert this document object to bitmap? How can i configure build in printer with android PrintService

Upvotes: 2

Views: 2135

Answers (1)

Ahmed Almahdie
Ahmed Almahdie

Reputation: 69

I hope I'm not too late. If you take a look at this question, you would find some helpful code and insights into the way I've solved this very issue you were/are having. My solution was some kind of union between the code in this Zaki50 PrintService, and this Thermal Print Service Repo. If it is helping, you could comment to that affect, and I will post the behaviour from the answer to my question here as well, so that you would accept it as an answer.

Upvotes: 0

Related Questions