我有 PAX A920,我正在尝试从 chrome 打印收据。我想在 android 中配置打印机服务以从我的内置打印机打印收据我已经为本地打印机编写了打印机服务,它正在预览中显示,但我不知道如何配置内置打印机。这是本地打印机的代码
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);
我也得到了 Document 对象
final PrintDocument document = printJob.getDocument();
但我不能利用这个文件在客户打印机中设置,我的客户打印机接受文本和位图的有效负载。这是从 PAX A920 打印的代码
PrintPayload payload = new PrintPayload();
payload.append(bmp).align(Alignment.CENTER);
print(payload);
如何将此document
对象转换为位图?如何使用 android PrintService 配置内置打印机