如何将PDF从android手机打印到打印机?
我试图将pdf文件作为字节数组发送到打印机,但它是用机器语言打印的。请任何人帮忙。我们正在使用hp officejet 100移动打印机,尝试通过蓝牙技术进行打印 //发送数据如何将PDF从android手机打印到打印机?,android,printing,bluetooth,Android,Printing,Bluetooth,我试图将pdf文件作为字节数组发送到打印机,但它是用机器语言打印的。请任何人帮忙。我们正在使用hp officejet 100移动打印机,尝试通过蓝牙技术进行打印 //发送数据 void sendData() throws IOException { try { InputStream is = new FileInputStream(new File(Environment.getExternalStorageDirectory().getAbsolu
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();
}
}
正在打印文本文件。。但不是图像和Pdf文件!!!!!我假设您可能已经找到了打印机的客户线程:否则,像PrintShare这样的解决方案可能完成了所有工作,以确定与打印机通信的协议,类似于@John SOlink@Morrison是的,这是客户的要求。如果我能够发送图像,那么对我来说也可以