我正在尝试将收据从网站打印到蓝牙 POS 打印机 - 特别是来自浏览器的 Bixolon SPP-R200III。我已经设法通过蓝牙连接到打印机并使用他们的 Android 应用程序打印测试页,但系统本身无法将设备识别为打印机,因此在没有任何额外应用程序的情况下进行打印似乎不是一种选择。这甚至可能吗?如果不是,解决这个问题的最好和最简单的方法是什么?
1 回答
0
尝试创建打印服务并从 PrintJob 中提取数据。就我而言,我从数据中创建了一个 PDF 文件并从那里开始工作。
InputStream in = null;
//Create the pdf file
final File file = new File(getFilesDir(), "test.pdf");
try{
in = new FileInputStream(printJob
.getDocument().
getData()
.getFileDescriptor());
out = new FileOutputStream(file);
byte[] bufferZ = new byte[1024];
int read;
//write on the pdf file
while ((read = in.read(bufferZ)) != -1) {
out.write(bufferZ, 0, read);
}
//close the input and output stream
in.close();
out.flush();
out.close();
}
于 2020-09-17T17:34:24.013 回答