我正在尝试将pdf文件作为字节数组发送到打印机,但它是用机器语言打印的。请大家帮忙。我们正在使用hp officejet 100移动打印机,试图通过蓝牙技术进行打印
//发送数据
void sendData() throws IOException {
try {
InputStream is = new FileInputStream(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/invoices.pdf"));// Where this is Activity
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int FILE_CHUNK_SIZE = 1024 * 4;
byte[] b = new byte[FILE_CHUNK_SIZE];
int read = -1;
while ((read = is.read(b)) != -1) {
bos.write(b, 0, read);
}
byte[] bytes = bos.toByteArray();
mmOutputStream.write(bytes);
is.close();
bos.close();
} catch (NullPointerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
myLabel.setText("Data Sent");
closeBT();
}
}